Skip to content

Commit

Permalink
Merge branch 'batch-metadata' of github.com:ctiller/grpc into one-pass
Browse files Browse the repository at this point in the history
Conflicts:
	src/core/channel/http_client_filter.c
	src/core/channel/http_server_filter.c
  • Loading branch information
ctiller committed Apr 22, 2015
2 parents 58ce3f0 + 48b02ec commit 77979b0
Show file tree
Hide file tree
Showing 124 changed files with 34,380 additions and 13,996 deletions.
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# GRPC Bazel BUILD file.
# This currently builds C and C++ code.
# This file has been automatically generated from a template file.
# Please look at the templates directory instead.

# Copyright 2015, Google Inc.
# All rights reserved.
Expand Down
15,406 changes: 10,904 additions & 4,502 deletions Makefile

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@
"test/cpp/qps/timer.cc"
],
"deps": [
"grpc_test_util"
"grpc_test_util",
"grpc++_test_util"
]
},
{
Expand Down
66 changes: 66 additions & 0 deletions gRPC.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Pod::Spec.new do |s|
s.name = 'gRPC'
s.version = '0.0.1'
s.summary = 'Generic gRPC client library for iOS'
s.homepage = 'https://www.grpc.io'
s.license = 'New BSD'
s.authors = { 'Jorge Canizales' => 'jcanizales@google.com' }

# s.source = { :git => 'https://github.com/grpc/grpc.git', :tag => 'release-0_5_0' }
s.source_files = 'src/objective-c/GRPCClient/*.{h,m}', 'src/objective-c/GRPCClient/private/*.{h,m}'
s.private_header_files = 'src/objective-c/GRPCClient/private/*.h'

s.platform = :ios
s.ios.deployment_target = '6.0'
s.requires_arc = true

s.subspec 'RxLibrary' do |rs|
rs.summary = 'Reactive Extensions library for iOS'
rs.authors = { 'Jorge Canizales' => 'jcanizales@google.com' }

rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}', 'src/objective-c/RxLibrary/transformations/*.{h,m}', 'src/objective-c/RxLibrary/private/*.{h,m}'
rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
end

s.subspec 'C-Core' do |cs|
cs.summary = 'Core gRPC library, written in C'
cs.authors = { 'Craig Tiller' => 'ctiller@google.com',
'David Klempner' => 'klempner@google.com',
'Nicolas Noble' => 'nnoble@google.com',
'Vijay Pai' => 'vpai@google.com',
'Yang Gao' => 'yangg@google.com' }

cs.source_files = 'src/core/**/*.{h,c}', 'include/grpc/*.h', 'include/grpc/**/*.h'
cs.private_header_files = 'src/core/**/*.h'
cs.header_mappings_dir = '.'
cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Build/gRPC" "$(PODS_ROOT)/Headers/Build/gRPC/include"' }

cs.requires_arc = false
cs.libraries = 'z'
cs.dependency 'OpenSSL', '~> 1.0.200'
end

# This is a workaround for Cocoapods Issue #1437.
# It renames time.h and string.h to grpc_time.h and grpc_string.h.
s.prepare_command = <<-CMD
DIR_TIME="grpc/support"
BAD_TIME="$DIR_TIME/time.h"
GOOD_TIME="$DIR_TIME/grpc_time.h"
if [ -f "include/$BAD_TIME" ];
then
grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
mv "include/$BAD_TIME" "include/$GOOD_TIME"
fi
DIR_STRING="src/core/support"
BAD_STRING="$DIR_STRING/string.h"
GOOD_STRING="$DIR_STRING/grpc_string.h"
if [ -f "$BAD_STRING" ];
then
grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
mv "$BAD_STRING" "$GOOD_STRING"
fi
CMD

s.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
end
8 changes: 4 additions & 4 deletions src/core/channel/http_client_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ static void hc_start_transport_op(grpc_call_element *elem, grpc_transport_op *op
/* Send : prefixed headers, which have to be before any application
layer headers. */
grpc_metadata_batch_add_head(&op->data.metadata, &calld->method,
grpc_mdelem_ref(channeld->method));
grpc_mdelem_ref(channeld->method));
grpc_metadata_batch_add_head(&op->data.metadata, &calld->scheme,
grpc_mdelem_ref(channeld->scheme));
grpc_mdelem_ref(channeld->scheme));
grpc_metadata_batch_add_tail(&op->data.metadata, &calld->te_trailers,
grpc_mdelem_ref(channeld->te_trailers));
grpc_mdelem_ref(channeld->te_trailers));
grpc_metadata_batch_add_tail(&op->data.metadata, &calld->content_type,
grpc_mdelem_ref(channeld->content_type));
grpc_mdelem_ref(channeld->content_type));
break;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/channel/http_server_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ static void hs_on_recv(void *user_data, int success) {
calld->seen_path) {
/* do nothing */
} else {
if (!calld->seen_path) {
gpr_log(GPR_ERROR, "Missing :path header");
}
if (!calld->seen_post) {
gpr_log(GPR_ERROR, "Missing :method header");
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/security/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem,

switch (op->type) {
case GRPC_SEND_METADATA:
for (l = op->data.metadata.list.head; l; l = l->next) {
for (l = op->data.metadata.list.head; l != NULL; l = l->next) {
grpc_mdelem *md = l->md;
/* Pointer comparison is OK for md_elems created from the same context.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/core/surface/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ static grpc_mdelem_list chain_metadata_from_app(grpc_call *call, size_t count,
grpc_metadata *next_md = (i == count - 1) ? NULL : &metadata[i + 1];
grpc_metadata *prev_md = (i == 0) ? NULL : &metadata[i - 1];
grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data;
assert(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
l->md = grpc_mdelem_from_string_and_buffer(call->metadata_context, md->key,
(const gpr_uint8 *)md->value,
md->value_length);
Expand Down Expand Up @@ -942,7 +942,7 @@ int grpc_call_recv_metadata(grpc_call_element *elem, grpc_metadata_batch *md) {

lock(call);
is_trailing = call->read_state >= READ_STATE_GOT_INITIAL_METADATA;
for (l = md->list.head; l; l = l->next) {
for (l = md->list.head; l != NULL; l = l->next) {
grpc_mdelem *md = l->md;
grpc_mdstr *key = md->key;
if (key == grpc_channel_get_status_string(call->channel)) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/transport/stream_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void assert_contained_metadata_ok(grpc_stream_op *ops, size_t nops) {
grpc_metadata_batch_assert_ok(&ops[i].data.metadata);
}
}
#endif
#endif /* NDEBUG */
}

static void expandto(grpc_stream_op_buffer *sopb, size_t new_capacity) {
Expand Down Expand Up @@ -201,15 +201,15 @@ static void assert_valid_list(grpc_mdelem_list *list) {
if (l->next) GPR_ASSERT(l->next->prev == l);
if (l->prev) GPR_ASSERT(l->prev->next == l);
}
#endif
#endif /* NDEBUG */
}

#ifndef NDEBUG
void grpc_metadata_batch_assert_ok(grpc_metadata_batch *comd) {
assert_valid_list(&comd->list);
assert_valid_list(&comd->garbage);
}
#endif
#endif /* NDEBUG */

void grpc_metadata_batch_init(grpc_metadata_batch *comd) {
comd->list.head = comd->list.tail = comd->garbage.head = comd->garbage.tail =
Expand Down
20 changes: 16 additions & 4 deletions src/csharp/Grpc.Core/Grpc.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,6 +12,7 @@
<RootNamespace>Grpc.Core</RootNamespace>
<AssemblyName>Grpc.Core</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>8bb563fb</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -92,15 +95,24 @@
ignored, which gives us the desired effect. -->
<When Condition=" '$(OS)' != 'Unix' ">
<ItemGroup>
<Content Include="..\..\..\vsprojects\vs2013\Debug\grpc_csharp_ext.dll">
<Content Include="..\..\..\vsprojects\Debug\grpc_csharp_ext.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</When>
<Otherwise />
</Choose>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Stub\" />
</ItemGroup>
<ItemGroup />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
</Project>
2 changes: 2 additions & 0 deletions src/csharp/Grpc.Core/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
<package id="System.Collections.Immutable" version="1.1.34-rc" targetFramework="net45" />
</packages>
19 changes: 17 additions & 2 deletions src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,25 @@ function loadObject(value) {
/**
* Load a gRPC object from a .proto file.
* @param {string} filename The file to load
* @param {string=} format The file format to expect. Must be either 'proto' or
* 'json'. Defaults to 'proto'
* @return {Object<string, *>} The resulting gRPC object
*/
function load(filename) {
var builder = ProtoBuf.loadProtoFile(filename);
function load(filename, format) {
if (!format) {
format = 'proto';
}
var builder;
switch(format) {
case 'proto':
builder = ProtoBuf.loadProtoFile(filename);
break;
case 'json':
builder = ProtoBuf.loadJsonFile(filename);
break;
default:
throw new Error('Unrecognized format "' + format + '"');
}

return loadObject(builder.ns);
}
Expand Down
22 changes: 22 additions & 0 deletions src/node/test/surface_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ var mathService = math_proto.lookup('math.Math');

var capitalize = require('underscore.string/capitalize');

describe('File loader', function() {
it('Should load a proto file by default', function() {
assert.doesNotThrow(function() {
grpc.load(__dirname + '/test_service.proto');
});
});
it('Should load a proto file with the proto format', function() {
assert.doesNotThrow(function() {
grpc.load(__dirname + '/test_service.proto', 'proto');
});
});
it('Should load a json file with the json format', function() {
assert.doesNotThrow(function() {
grpc.load(__dirname + '/test_service.json', 'json');
});
});
it('Should fail to load a file with an unknown format', function() {
assert.throws(function() {
grpc.load(__dirname + '/test_service.proto', 'fake_format');
});
});
});
describe('Surface server constructor', function() {
it('Should fail with conflicting method names', function() {
assert.throws(function() {
Expand Down
55 changes: 55 additions & 0 deletions src/node/test/test_service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"package": null,
"messages": [
{
"name": "Request",
"fields": [
{
"rule": "optional",
"type": "bool",
"name": "error",
"id": 1
}
]
},
{
"name": "Response",
"fields": [
{
"rule": "optional",
"type": "int32",
"name": "count",
"id": 1
}
]
}
],
"services": [
{
"name": "TestService",
"options": {},
"rpc": {
"Unary": {
"request": "Request",
"response": "Response",
"options": {}
},
"ClientStream": {
"request": "Request",
"response": "Response",
"options": {}
},
"ServerStream": {
"request": "Request",
"response": "Response",
"options": {}
},
"BidiStream": {
"request": "Request",
"response": "Response",
"options": {}
}
}
}
]
}
2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/GRPCCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/

#import <Foundation/Foundation.h>
#import <RxLibrary/GRXWriter.h>
#import <gRPC/GRXWriter.h>

@class GRPCMethodName;

Expand Down
4 changes: 2 additions & 2 deletions src/objective-c/GRPCClient/GRPCCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

#import "GRPCCall.h"

#include <grpc.h>
#include <support/time.h>
#include <grpc/grpc.h>
#include <grpc/support/grpc_time.h>

#import "GRPCMethodName.h"
#import "private/GRPCChannel.h"
Expand Down
14 changes: 0 additions & 14 deletions src/objective-c/GRPCClient/GRPCClient.podspec

This file was deleted.

2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/private/GRPCChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#import "GRPCChannel.h"

#import <grpc.h>
#import <grpc/grpc.h>

@implementation GRPCChannel

Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#import "GRPCCompletionQueue.h"

#import <grpc.h>
#import <grpc/grpc.h>

@implementation GRPCCompletionQueue

Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#import "GRPCDelegateWrapper.h"

#import <RxLibrary/GRXWriteable.h>
#import <gRPC/GRXWriteable.h>

@interface GRPCDelegateWrapper ()
// These are atomic so that cancellation can nillify them from any thread.
Expand Down
Loading

0 comments on commit 77979b0

Please sign in to comment.