forked from facebookincubator/gloo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamic loading of OpenSSL (facebookincubator#302)
Summary: Pull Request resolved: facebookincubator#302 Test Plan: Imported from OSS Reviewed By: malfet Differential Revision: D27781296 Pulled By: pbelevich fbshipit-source-id: 4544d62518ea22017df11d728cc530888360d398
- Loading branch information
1 parent
1b62018
commit 2e0fe46
Showing
15 changed files
with
342 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
message(WARNING "Gloo doesn't support OSX (uses epoll)") | ||
else() | ||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
message(WARNING "Gloo TCP-TLS transport is supported only on Linux(uses epoll API)") | ||
else () | ||
list(APPEND GLOO_TRANSPORT_SRCS | ||
"${CMAKE_CURRENT_SOURCE_DIR}/context.cc" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/device.cc" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/openssl.cc" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pair.cc" | ||
) | ||
list(APPEND GLOO_TRANSPORT_HDRS | ||
"${CMAKE_CURRENT_SOURCE_DIR}/context.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/device.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/openssl.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pair.h" | ||
) | ||
if (USE_TCP_OPENSSL_LOAD) | ||
list(APPEND GLOO_TRANSPORT_SRCS | ||
"${CMAKE_CURRENT_SOURCE_DIR}/context.cc" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/device.cc" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pair.cc" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/dynamic_library.cc" | ||
) | ||
list(APPEND GLOO_TRANSPORT_HDRS | ||
"${CMAKE_CURRENT_SOURCE_DIR}/context.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/device.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pair.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/dynamic_library.h" | ||
) | ||
endif() | ||
endif () | ||
endif () | ||
|
||
set(GLOO_TRANSPORT_SRCS ${GLOO_TRANSPORT_SRCS} PARENT_SCOPE) | ||
set(GLOO_TRANSPORT_HDRS ${GLOO_TRANSPORT_HDRS} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "dynamic_library.h" | ||
|
||
#include <dlfcn.h> | ||
#include <stdexcept> | ||
|
||
DynamicLibrary::DynamicLibrary(const char *name, const char *alt_name) | ||
: lib_name(name) { | ||
handle = dlopen(name, RTLD_LOCAL | RTLD_NOW); | ||
if (!handle) { | ||
if (alt_name == nullptr) { | ||
throw std::runtime_error(dlerror()); | ||
} else { | ||
handle = dlopen(alt_name, RTLD_LOCAL | RTLD_NOW); | ||
if (!handle) { | ||
throw std::runtime_error(dlerror()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void *DynamicLibrary::sym(const char *name) { | ||
void *res = dlsym(handle, name); | ||
if (res == nullptr) { | ||
throw std::runtime_error("Can't find " + std::string(name) + " in " + | ||
lib_name + ":" + dlerror()); | ||
} | ||
return res; | ||
} | ||
|
||
DynamicLibrary::~DynamicLibrary() { | ||
if (!handle) | ||
return; | ||
dlclose(handle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2021-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
struct DynamicLibrary { | ||
DynamicLibrary(const DynamicLibrary &) = delete; | ||
|
||
void operator=(const DynamicLibrary &) = delete; | ||
|
||
DynamicLibrary(const char *name, const char *alt_name); | ||
|
||
void *sym(const char *name); | ||
|
||
~DynamicLibrary(); | ||
|
||
private: | ||
const std::string lib_name; | ||
void *handle = nullptr; | ||
}; |
Oops, something went wrong.