From 96d9dc34ffd48e45a4ecdb7aedc5906e336d9517 Mon Sep 17 00:00:00 2001 From: Dan Born Date: Tue, 2 Feb 2016 14:57:36 -0800 Subject: [PATCH 1/7] Fix comments in tcp_server.h --- src/core/iomgr/tcp_server.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/iomgr/tcp_server.h b/src/core/iomgr/tcp_server.h index 8f3184ff1e0..a39dd3bafce 100644 --- a/src/core/iomgr/tcp_server.h +++ b/src/core/iomgr/tcp_server.h @@ -40,15 +40,14 @@ /* Forward decl of grpc_tcp_server */ typedef struct grpc_tcp_server grpc_tcp_server; -typedef struct grpc_tcp_server_acceptor grpc_tcp_server_acceptor; -struct grpc_tcp_server_acceptor { +typedef struct grpc_tcp_server_acceptor { /* grpc_tcp_server_cb functions share a ref on from_server that is valid until the function returns. */ grpc_tcp_server *from_server; /* Indices that may be passed to grpc_tcp_server_port_fd(). */ unsigned port_index; unsigned fd_index; -}; +} grpc_tcp_server_acceptor; /* Called for newly connected TCP connections. */ typedef void (*grpc_tcp_server_cb)(grpc_exec_ctx *exec_ctx, void *arg, @@ -57,7 +56,7 @@ typedef void (*grpc_tcp_server_cb)(grpc_exec_ctx *exec_ctx, void *arg, /* Create a server, initially not bound to any ports. The caller owns one ref. If shutdown_complete is not NULL, it will be used by - grpc_tcp_server_unref(). */ + grpc_tcp_server_unref() when the ref count reaches zero. */ grpc_tcp_server *grpc_tcp_server_create(grpc_closure *shutdown_complete); /* Start listening to bound ports */ @@ -84,7 +83,7 @@ unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s, unsigned port_index); /* Returns the file descriptor of the Mth (fd_index) listening socket of the Nth (port_index) call to add_port() on this server, or -1 if the indices are out of bounds. The file descriptor remains owned by the server, and will be - cleaned up when grpc_tcp_server_destroy is called. */ + cleaned up when the ref count reaches zero. */ int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index, unsigned fd_index); @@ -97,7 +96,7 @@ grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s); void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s, grpc_closure *shutdown_starting); -/* If the recount drops to zero, delete s, and call (exec_ctx==NULL) or enqueue +/* If the refcount drops to zero, delete s, and call (exec_ctx==NULL) or enqueue a call (exec_ctx!=NULL) to shutdown_complete. */ void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s); From b767d09c315044885f68a65eed9131c02299dc16 Mon Sep 17 00:00:00 2001 From: Chris Bacon Date: Thu, 4 Feb 2016 16:22:59 +0000 Subject: [PATCH 2/7] Fix NativeExtensions for coreclr Coreclr doesn't support Assembly.GetExecutingAssembly(), use TypeInfo.Assembly instead, which is supported on all platforms. --- src/csharp/Grpc.Core/Internal/NativeExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/Internal/NativeExtension.cs b/src/csharp/Grpc.Core/Internal/NativeExtension.cs index e14d33ea506..4c742ab6c3d 100644 --- a/src/csharp/Grpc.Core/Internal/NativeExtension.cs +++ b/src/csharp/Grpc.Core/Internal/NativeExtension.cs @@ -106,7 +106,7 @@ namespace Grpc.Core.Internal private static string GetExecutingAssemblyDirectory() { - return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + return Path.GetDirectoryName(typeof(NativeExtension).GetTypeInfo().Assembly.Location); } private static string GetPlatformString() From 07a6be99bd2ac039bfef797f05ce76b020645230 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Feb 2016 12:40:41 -0800 Subject: [PATCH 3/7] Stop upsetting valgrind with uninitialized shorts --- src/core/support/stack_lockfree.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c index cd0afddf9df..c18fb65ae65 100644 --- a/src/core/support/stack_lockfree.c +++ b/src/core/support/stack_lockfree.c @@ -99,6 +99,10 @@ gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) { /* Point the head at reserved dummy entry */ stack->head.contents.index = INVALID_ENTRY_INDEX; +#ifdef GPR_ARCH_64 + stack->head.contents.pad = 0; +#endif + stack->head.contents.aba_ctr = 0; return stack; } @@ -115,6 +119,10 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) { /* First fill in the entry's index and aba ctr for new head */ newhead.contents.index = (uint16_t)entry; +#ifdef GPR_ARCH_64 + newhead.contents.pad = 0; +#endif + /* Also post-increment the aba_ctr */ curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm); newhead.contents.aba_ctr = ++curent.contents.aba_ctr; From 663a29144ae01fb421ae84e533852c8423c63452 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Feb 2016 13:19:50 -0800 Subject: [PATCH 4/7] Add explicit comments about purpose of writing to pad --- src/core/support/stack_lockfree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c index c18fb65ae65..b2f58803528 100644 --- a/src/core/support/stack_lockfree.c +++ b/src/core/support/stack_lockfree.c @@ -100,6 +100,7 @@ gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) { /* Point the head at reserved dummy entry */ stack->head.contents.index = INVALID_ENTRY_INDEX; #ifdef GPR_ARCH_64 + // Fill in the pad to avoid confusing memcheck tools stack->head.contents.pad = 0; #endif stack->head.contents.aba_ctr = 0; @@ -120,6 +121,7 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) { /* First fill in the entry's index and aba ctr for new head */ newhead.contents.index = (uint16_t)entry; #ifdef GPR_ARCH_64 + // Fill in the pad to avoid confusing memcheck tools newhead.contents.pad = 0; #endif From ee7a88c7d242f73e1f1bddc0bf7a3e15a65eee4f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 4 Feb 2016 17:00:44 -0800 Subject: [PATCH 5/7] fix note distribtest nvm problem --- test/distrib/node/run_distrib_test.sh | 6 +++--- tools/run_tests/distribtest_targets.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/distrib/node/run_distrib_test.sh b/test/distrib/node/run_distrib_test.sh index dbbcad25e42..90637cc01d0 100755 --- a/test/distrib/node/run_distrib_test.sh +++ b/test/distrib/node/run_distrib_test.sh @@ -36,17 +36,17 @@ nvm install $1 npm install -g node-static -STATIC_SERVER=localhost +STATIC_SERVER=127.0.0.1 STATIC_PORT=8080 # Serves the input_artifacts directory statically at localhost:8080 -static "$EXTERNAL_GIT_ROOT/input_artifacts" -a STATIC_SERVER -p STATIC_PORT & +static "$EXTERNAL_GIT_ROOT/input_artifacts" -a $STATIC_SERVER -p $STATIC_PORT & STATIC_PID=$! STATIC_URL="http://$STATIC_SERVER:$STATIC_PORT/" npm install --unsafe-perm $STATIC_URL/grpc.tgz --grpc_node_binary_host_mirror=$STATIC_URL -kill $STATIC_PID +kill -9 $STATIC_PID ./distrib_test.js diff --git a/tools/run_tests/distribtest_targets.py b/tools/run_tests/distribtest_targets.py index 7fd0800fa0f..e9a80d2cf40 100644 --- a/tools/run_tests/distribtest_targets.py +++ b/tools/run_tests/distribtest_targets.py @@ -104,7 +104,8 @@ class NodeDistribTest(object): 'tools/dockerfile/distribtest/node_%s_%s' % ( self.docker_suffix, self.arch), - 'test/distrib/node/run_distrib_test.sh %s' % ( + # bash -l needed to make nvm available + 'bash -l test/distrib/node/run_distrib_test.sh %s' % ( self.node_version)) def __str__(self): return self.name From 0c598b08ac06a5e2b1a4ed022bbb60e4e999624e Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 4 Feb 2016 18:02:26 -0800 Subject: [PATCH 6/7] Fix copyright and use consistent C89 comments --- src/core/support/stack_lockfree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c index b2f58803528..2c97ee18be1 100644 --- a/src/core/support/stack_lockfree.c +++ b/src/core/support/stack_lockfree.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,8 +99,8 @@ gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) { /* Point the head at reserved dummy entry */ stack->head.contents.index = INVALID_ENTRY_INDEX; + /* Fill in the pad and aba_ctr to avoid confusing memcheck tools */ #ifdef GPR_ARCH_64 - // Fill in the pad to avoid confusing memcheck tools stack->head.contents.pad = 0; #endif stack->head.contents.aba_ctr = 0; @@ -121,7 +121,7 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) { /* First fill in the entry's index and aba ctr for new head */ newhead.contents.index = (uint16_t)entry; #ifdef GPR_ARCH_64 - // Fill in the pad to avoid confusing memcheck tools + /* Fill in the pad to avoid confusing memcheck tools */ newhead.contents.pad = 0; #endif From 95060b510e181588a7229ee498594a5864cf9926 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 5 Feb 2016 13:05:31 -0800 Subject: [PATCH 7/7] Make Node examples package self-contained --- examples/node/greeter_client.js | 4 ++-- examples/node/greeter_server.js | 4 ++-- examples/node/package.json | 7 +++++++ examples/node/route_guide/route_guide_client.js | 6 +++--- examples/node/route_guide/route_guide_server.js | 6 +++--- 5 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 examples/node/package.json diff --git a/examples/node/greeter_client.js b/examples/node/greeter_client.js index e0b89bd376a..9b4b0a77829 100644 --- a/examples/node/greeter_client.js +++ b/examples/node/greeter_client.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ var PROTO_PATH = __dirname + '/helloworld.proto'; -var grpc = require('../../'); +var grpc = require('grpc'); var hello_proto = grpc.load(PROTO_PATH).helloworld; function main() { diff --git a/examples/node/greeter_server.js b/examples/node/greeter_server.js index 3600c8bfbf4..2712b3dd3ad 100644 --- a/examples/node/greeter_server.js +++ b/examples/node/greeter_server.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ var PROTO_PATH = __dirname + '/helloworld.proto'; -var grpc = require('../../'); +var grpc = require('grpc'); var hello_proto = grpc.load(PROTO_PATH).helloworld; /** diff --git a/examples/node/package.json b/examples/node/package.json new file mode 100644 index 00000000000..65c5789ed7b --- /dev/null +++ b/examples/node/package.json @@ -0,0 +1,7 @@ +{ + "name": "grpc-examples", + "version": "0.1.0", + "dependencies": { + "grpc": "0.12.0" + } +} diff --git a/examples/node/route_guide/route_guide_client.js b/examples/node/route_guide/route_guide_client.js index edeca6ff553..e38a21f4228 100644 --- a/examples/node/route_guide/route_guide_client.js +++ b/examples/node/route_guide/route_guide_client.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,13 +30,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + var async = require('async'); var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); var _ = require('lodash'); -var grpc = require('../../../'); +var grpc = require('grpc'); var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide; var client = new routeguide.RouteGuide('localhost:50051', grpc.Credentials.createInsecure()); diff --git a/examples/node/route_guide/route_guide_server.js b/examples/node/route_guide/route_guide_server.js index 2090a6a1d2f..06cf2925e1c 100644 --- a/examples/node/route_guide/route_guide_server.js +++ b/examples/node/route_guide/route_guide_server.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,12 +30,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); var _ = require('lodash'); -var grpc = require('../../../'); +var grpc = require('grpc'); var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide; var COORD_FACTOR = 1e7;