aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-02-02 20:14:56 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-02-02 20:14:56 +0100
commit8696d577d680deec004c1cd0a8826a2e33a83c36 (patch)
tree15afb01915219a0f8bc757dd0d45572026ac5c7b /src
parentdc5cf55257f79b45ef044e53057f2d0d355e4014 (diff)
parent4d48522f0075884b2b57ff24a65fee76b918e52f (diff)
Merge branch 'master' of github.com:grpc/grpc into make-ruby-installable
Diffstat (limited to 'src')
-rw-r--r--src/core/support/env_linux.c24
-rw-r--r--src/core/support/time_posix.c13
-rw-r--r--src/csharp/Grpc.Core/Internal/PlatformApis.cs7
-rw-r--r--src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs24
-rw-r--r--src/proto/grpc/testing/control.proto20
-rw-r--r--src/proto/grpc/testing/services.proto5
6 files changed, 86 insertions, 7 deletions
diff --git a/src/core/support/env_linux.c b/src/core/support/env_linux.c
index 2e03365e33..b5832a5917 100644
--- a/src/core/support/env_linux.c
+++ b/src/core/support/env_linux.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
@@ -49,8 +49,28 @@
#include "src/core/support/string.h"
+/* Declare weak symbols for versions of secure_getenv that *may* be
+ * on a users machine. Older libc's call this __secure_getenv, even
+ * older don't support the functionality.
+ *
+ * If a symbol is not present, these will be equal to NULL.
+ */
+char *__attribute__((weak)) secure_getenv(const char *name);
+char *__attribute__((weak)) __secure_getenv(const char *name);
+
char *gpr_getenv(const char *name) {
- char *result = secure_getenv(name);
+ static char *(*getenv_func)(const char *) = secure_getenv;
+ /* Check to see which getenv variant is supported (go from most
+ * to least secure) */
+ if (getenv_func == NULL) {
+ getenv_func = __secure_getenv;
+ if (getenv_func == NULL) {
+ gpr_log(GPR_DEBUG,
+ "No secure_getenv. Please consider upgrading your libc.");
+ getenv_func = getenv;
+ }
+ }
+ char *result = getenv_func(name);
return result == NULL ? result : gpr_strdup(result);
}
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c
index 06bb78c913..1f92d7f090 100644
--- a/src/core/support/time_posix.c
+++ b/src/core/support/time_posix.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
@@ -39,6 +39,9 @@
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
+#ifdef __linux__
+#include <sys/syscall.h>
+#endif
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/support/block_annotate.h"
@@ -70,7 +73,8 @@ static gpr_timespec gpr_from_timespec(struct timespec ts,
}
/** maps gpr_clock_type --> clockid_t for clock_gettime */
-static clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, CLOCK_REALTIME};
+static const clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC,
+ CLOCK_REALTIME};
void gpr_time_init(void) { gpr_precise_clock_init(); }
@@ -82,7 +86,12 @@ gpr_timespec gpr_now(gpr_clock_type clock_type) {
gpr_precise_clock_now(&ret);
return ret;
} else {
+#if defined(__linux__) && !defined(GPR_NO_DIRECT_SYSCALLS)
+ /* avoid ABI problems by invoking syscalls directly */
+ syscall(SYS_clock_gettime, clockid_for_gpr_clock[clock_type], &now);
+#else
clock_gettime(clockid_for_gpr_clock[clock_type], &now);
+#endif
return gpr_from_timespec(now, clock_type);
}
}
diff --git a/src/csharp/Grpc.Core/Internal/PlatformApis.cs b/src/csharp/Grpc.Core/Internal/PlatformApis.cs
index d71e7eccdd..f0c5b0f63f 100644
--- a/src/csharp/Grpc.Core/Internal/PlatformApis.cs
+++ b/src/csharp/Grpc.Core/Internal/PlatformApis.cs
@@ -49,6 +49,7 @@ namespace Grpc.Core.Internal
static readonly bool isLinux;
static readonly bool isMacOSX;
static readonly bool isWindows;
+ static readonly bool isMono;
static PlatformApis()
{
@@ -58,6 +59,7 @@ namespace Grpc.Core.Internal
isMacOSX = (platform == PlatformID.Unix && GetUname() == "Darwin");
isLinux = (platform == PlatformID.Unix && !isMacOSX);
isWindows = (platform == PlatformID.Win32NT || platform == PlatformID.Win32S || platform == PlatformID.Win32Windows);
+ isMono = Type.GetType("Mono.Runtime") != null;
}
public static bool IsLinux
@@ -75,6 +77,11 @@ namespace Grpc.Core.Internal
get { return isWindows; }
}
+ public static bool IsMono
+ {
+ get { return isMono; }
+ }
+
public static bool Is64Bit
{
get { return IntPtr.Size == 8; }
diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
index e614cab6ab..95a8797e3e 100644
--- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
+++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
@@ -91,6 +91,10 @@ namespace Grpc.Core.Internal
{
if (PlatformApis.IsLinux)
{
+ if (PlatformApis.IsMono)
+ {
+ return Mono.dlsym(this.handle, symbolName);
+ }
return Linux.dlsym(this.handle, symbolName);
}
if (PlatformApis.IsMacOSX)
@@ -122,6 +126,10 @@ namespace Grpc.Core.Internal
}
if (PlatformApis.IsLinux)
{
+ if (PlatformApis.IsMono)
+ {
+ return Mono.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY);
+ }
return Linux.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY);
}
if (PlatformApis.IsMacOSX)
@@ -154,5 +162,21 @@ namespace Grpc.Core.Internal
[DllImport("libSystem.dylib")]
internal static extern IntPtr dlsym(IntPtr handle, string symbol);
}
+
+ /// <summary>
+ /// On Linux systems, using using dlopen and dlsym results in
+ /// DllNotFoundException("libdl.so not found") if libc6-dev
+ /// is not installed. As a workaround, we load symbols for
+ /// dlopen and dlsym from the current process as on Linux
+ /// Mono sure is linked against these symbols.
+ /// </summary>
+ private static class Mono
+ {
+ [DllImport("__Internal")]
+ internal static extern IntPtr dlopen(string filename, int flags);
+
+ [DllImport("__Internal")]
+ internal static extern IntPtr dlsym(IntPtr handle, string symbol);
+ }
}
}
diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto
index 2f352e652f..8278836468 100644
--- a/src/proto/grpc/testing/control.proto
+++ b/src/proto/grpc/testing/control.proto
@@ -107,6 +107,10 @@ message ClientConfig {
LoadParams load_params = 10;
PayloadConfig payload_config = 11;
HistogramParams histogram_params = 12;
+
+ // Specify the cores we should run the client on, if desired
+ repeated int32 core_list = 13;
+ int32 core_limit = 14;
}
message ClientStatus { ClientStats stats = 1; }
@@ -131,9 +135,13 @@ message ServerConfig {
int32 port = 4;
// Only for async server. Number of threads used to serve the requests.
int32 async_server_threads = 7;
- // restrict core usage, currently unused
+ // Specify the number of cores to limit server to, if desired
int32 core_limit = 8;
+ // payload config, used in generic server
PayloadConfig payload_config = 9;
+
+ // Specify the cores we should run the server on, if desired
+ repeated int32 core_list = 10;
}
message ServerArgs {
@@ -147,6 +155,14 @@ message ServerStatus {
ServerStats stats = 1;
// the port bound by the server
int32 port = 2;
- // Number of cores on the server. See gpr_cpu_num_cores.
+ // Number of cores available to the server
int32 cores = 3;
}
+
+message CoreRequest {
+}
+
+message CoreResponse {
+ // Number of cores available on the server
+ int32 cores = 1;
+}
diff --git a/src/proto/grpc/testing/services.proto b/src/proto/grpc/testing/services.proto
index af285ceab8..4c8e32bb8f 100644
--- a/src/proto/grpc/testing/services.proto
+++ b/src/proto/grpc/testing/services.proto
@@ -1,4 +1,4 @@
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -62,4 +62,7 @@ service WorkerService {
// and once the shutdown has finished, the OK status is sent to terminate
// this RPC.
rpc RunClient(stream ClientArgs) returns (stream ClientStatus);
+
+ // Just return the core count - unary call
+ rpc CoreCount(CoreRequest) returns (CoreResponse);
}