Skip to content

Commit

Permalink
Merge github.com:grpc/grpc into optionalize_roundrobin
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Mar 29, 2016
2 parents 9c84fc3 + c91504e commit 797e278
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 93 deletions.
7 changes: 7 additions & 0 deletions include/grpc/impl/codegen/port_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_MSG_NOSIGNAL 1
#define GPR_HAVE_UNIX_SOCKET 1
#define GPR_HAVE_IP_PKTINFO 1
#define GPR_HAVE_IPV6_RECVPKTINFO 1
#elif defined(__linux__)
#define GPR_POSIX_CRASH_HANDLER 1
#define GPR_PLATFORM_STRING "linux"
Expand All @@ -156,6 +158,8 @@
#define GPR_POSIX_SOCKET 1
#define GPR_POSIX_SOCKETADDR 1
#define GPR_HAVE_UNIX_SOCKET 1
#define GPR_HAVE_IP_PKTINFO 1
#define GPR_HAVE_IPV6_RECVPKTINFO 1
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 9)
#define GPR_LINUX_EVENTFD 1
Expand Down Expand Up @@ -217,6 +221,7 @@
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_SO_NOSIGPIPE 1
#define GPR_HAVE_UNIX_SOCKET 1
#define GPR_HAVE_IP_PKTINFO 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */
Expand Down Expand Up @@ -246,6 +251,8 @@
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_SO_NOSIGPIPE 1
#define GPR_HAVE_UNIX_SOCKET 1
#define GPR_HAVE_IP_PKTINFO 1
#define GPR_HAVE_IPV6_RECVPKTINFO 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"bundledDependencies": ["node-pre-gyp"],
"dependencies": {
"arguejs": "^0.2.3",
"lodash": "^3.9.3",
"nan": "^2.0.0",
"protobufjs": "^4.0.0"
Expand Down
22 changes: 22 additions & 0 deletions src/core/lib/iomgr/socket_utils_common_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ int grpc_set_socket_no_sigpipe_if_possible(int fd) {
#endif
}

int grpc_set_socket_ip_pktinfo_if_possible(int fd) {
#ifdef GPR_HAVE_IP_PKTINFO
int get_local_ip = 1;
return 0 == setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip,
sizeof(get_local_ip));
#else
(void)fd;
return 1;
#endif
}

int grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) {
#ifdef GPR_HAVE_IPV6_RECVPKTINFO
int get_local_ip = 1;
return 0 == setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip,
sizeof(get_local_ip));
#else
(void)fd;
return 1;
#endif
}

/* set a socket to close on exec */
int grpc_set_socket_cloexec(int fd, int close_on_exec) {
int oldflags = fcntl(fd, F_GETFD, 0);
Expand Down
10 changes: 10 additions & 0 deletions src/core/lib/iomgr/socket_utils_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ int grpc_ipv6_loopback_available(void);
If SO_NO_SIGPIPE is not available, returns 1. */
int grpc_set_socket_no_sigpipe_if_possible(int fd);

/* Tries to set IP_PKTINFO if available on this platform.
Returns 1 on success, 0 on failure.
If IP_PKTINFO is not available, returns 1. */
int grpc_set_socket_ip_pktinfo_if_possible(int fd);

/* Tries to set IPV6_RECVPKTINFO if available on this platform.
Returns 1 on success, 0 on failure.
If IPV6_RECVPKTINFO is not available, returns 1. */
int grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd);

/* An enum to keep track of IPv4/IPv6 socket modes.
Currently, this information is only used when a socket is first created, but
Expand Down
13 changes: 3 additions & 10 deletions src/core/lib/iomgr/udp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
size_t addr_len) {
struct sockaddr_storage sockname_temp;
socklen_t sockname_len;
int get_local_ip;
int rc;

if (fd < 0) {
goto error;
Expand All @@ -220,14 +218,9 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
strerror(errno));
}

get_local_ip = 1;
rc = setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip,
sizeof(get_local_ip));
if (rc == 0 && addr->sa_family == AF_INET6) {
#if !defined(__APPLE__)
rc = setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip,
sizeof(get_local_ip));
#endif
if (grpc_set_socket_ip_pktinfo_if_possible(fd) &&
addr->sa_family == AF_INET6) {
grpc_set_socket_ipv6_recvpktinfo_if_possible(fd);
}

GPR_ASSERT(addr_len < ~(socklen_t)0);
Expand Down
4 changes: 4 additions & 0 deletions src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ var loadObject = exports.loadObject;
* Buffers. Defaults to false
* - longsAsStrings: deserialize long values as strings instead of objects.
* Defaults to true
* - deprecatedArgumentOrder: Use the beta method argument order for client
* methods, with optional arguments after the callback. Defaults to false.
* This option is only a temporary stopgap measure to smooth an API breakage.
* It is deprecated, and new code should not use it.
* @param {string|{root: string, file: string}} filename The file to load
* @param {string=} format The file format to expect. Must be either 'proto' or
* 'json'. Defaults to 'proto'
Expand Down
10 changes: 5 additions & 5 deletions src/node/interop/interop_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function cancelAfterFirstResponse(client, done) {
function timeoutOnSleepingServer(client, done) {
var deadline = new Date();
deadline.setMilliseconds(deadline.getMilliseconds() + 1);
var call = client.fullDuplexCall(null, {deadline: deadline});
var call = client.fullDuplexCall({deadline: deadline});
call.write({
payload: {body: zeroBuffer(27182)}
});
Expand Down Expand Up @@ -316,10 +316,10 @@ function customMetadata(client, done) {
body: zeroBuffer(271828)
}
};
var unary = client.unaryCall(arg, function(err, resp) {
var unary = client.unaryCall(arg, metadata, function(err, resp) {
assert.ifError(err);
done();
}, metadata);
});
unary.on('metadata', function(metadata) {
assert.deepEqual(metadata.get(ECHO_INITIAL_KEY),
['test_initial_metadata_value']);
Expand Down Expand Up @@ -455,14 +455,14 @@ function perRpcAuthTest(client, done, extra) {
credential = credential.createScoped(scope);
}
var creds = grpc.credentials.createFromGoogleCredential(credential);
client.unaryCall(arg, function(err, resp) {
client.unaryCall(arg, {credentials: creds}, function(err, resp) {
assert.ifError(err);
assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
assert(extra.oauth_scope.indexOf(resp.oauth_scope) > -1);
if (done) {
done();
}
}, null, {credentials: creds});
});
});
}

Expand Down
Loading

0 comments on commit 797e278

Please sign in to comment.