aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-02-02 10:36:12 -0800
committerGravatar Vijay Pai <vpai@google.com>2016-02-02 10:36:12 -0800
commitb47b556d33c0e22601e773cad17d576197b4942b (patch)
tree96f3900c391a24e27182e00c4bf020a55b4cfdb9 /src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
parentd99ed6b636eca5d7ba38f19337f447aa0fbeebb9 (diff)
parent71a083b1b14cf6f9844d51e7e7c3b75de16c0501 (diff)
Merge branch 'master' into worker_quit
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs')
-rw-r--r--src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs24
1 files changed, 24 insertions, 0 deletions
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);
+ }
}
}