Changed generic plugin code to work as expected plugin code except for TLS use case
Defined TLS plugin name constant Changed TLS plugin name to get_tls_plugin Fixed link script Removed compilation flags from info make target
This commit is contained in:
parent
dd967bd9e2
commit
65d8b38ae9
|
@ -42,7 +42,7 @@ ITLSPolicy *FDBLibTLSPlugin::create_policy(ITLSLogFunc logf) {
|
|||
return new FDBLibTLSPolicy(Reference<FDBLibTLSPlugin>::addRef(this), logf);
|
||||
}
|
||||
|
||||
extern "C" BOOST_SYMBOL_EXPORT void *get_plugin(const char *plugin_type_name_and_version) {
|
||||
extern "C" BOOST_SYMBOL_EXPORT void *get_tls_plugin(const char *plugin_type_name_and_version) {
|
||||
if (strcmp(plugin_type_name_and_version, FDBLibTLSPlugin::get_plugin_type_name_and_version()) == 0) {
|
||||
return new FDBLibTLSPlugin;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ case $1 in
|
|||
fi
|
||||
;;
|
||||
*)
|
||||
\ $CC $OPTIONS
|
||||
$CC $OPTIONS
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -164,5 +164,4 @@ ifdef TLS_DISABLED
|
|||
else
|
||||
@echo "TLS: Enabled"
|
||||
endif
|
||||
@echo "fdbcli CFLAGS: $(fdbcli_CFLAGS)"
|
||||
@echo ""
|
||||
|
|
|
@ -20,14 +20,25 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// Will need to be defined at link time
|
||||
extern "C" void *get_plugin(const char *plugin_type_name_and_version);
|
||||
// Specialized TLS plugin library
|
||||
extern "C" void *get_tls_plugin(const char *plugin_type_name_and_version);
|
||||
|
||||
// Name of specialized TLS Plugin
|
||||
extern const char* tlsPluginName;
|
||||
|
||||
template <class T>
|
||||
Reference<T> loadPlugin( std::string const& plugin_name ) {
|
||||
#ifdef TLS_DISABLED
|
||||
return Reference<T>( NULL );
|
||||
#else
|
||||
return (plugin_name.empty()) ? Reference<T>( NULL ) : Reference<T>( (T*)get_plugin( T::get_plugin_type_name_and_version() ) );
|
||||
void *(*get_plugin)(const char*) = NULL;
|
||||
#ifndef TLS_DISABLED
|
||||
if (!plugin_name.compare(tlsPluginName)) {
|
||||
get_plugin = (void*(*)(const char*)) get_tls_plugin;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
void* plugin = loadLibrary( plugin_name.c_str() );
|
||||
if (plugin)
|
||||
get_plugin = (void*(*)(const char*))loadFunction( plugin, "get_plugin" );
|
||||
}
|
||||
return (get_plugin) ? Reference<T>( (T*)get_plugin( T::get_plugin_type_name_and_version() ) ) : Reference<T>( NULL );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include "Platform.h"
|
||||
#include <memory>
|
||||
|
||||
// Name of specialized TLS Plugin
|
||||
const char* tlsPluginName = "fdb-libressl-plugin";
|
||||
|
||||
// Must not throw an exception from this function!
|
||||
static int send_func(void* ctx, const uint8_t* buf, int len) {
|
||||
TLSConnection* conn = (TLSConnection*)ctx;
|
||||
|
@ -368,14 +371,13 @@ static void TLSConnectionLogFunc( const char* event, void* uid_ptr, bool is_erro
|
|||
}
|
||||
|
||||
void TLSOptions::init_plugin() {
|
||||
std::string plugin_path = platform::getDefaultPluginPath("fdb-libressl-plugin");
|
||||
|
||||
TraceEvent("TLSConnectionLoadingPlugin").detail("PluginPath", plugin_path);
|
||||
TraceEvent("TLSConnectionLoadingPlugin").detail("Plugin", tlsPluginName);
|
||||
|
||||
plugin = loadPlugin<ITLSPlugin>( plugin_path.c_str() );
|
||||
plugin = loadPlugin<ITLSPlugin>( tlsPluginName );
|
||||
|
||||
if ( !plugin ) {
|
||||
TraceEvent(SevError, "TLSConnectionPluginInitError").detail("Plugin", plugin_path).GetLastError();
|
||||
TraceEvent(SevError, "TLSConnectionPluginInitError").detail("Plugin", tlsPluginName).GetLastError();
|
||||
throw tls_error();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue