From b289eac3397efc9550b0e878bae8a6f682a560eb Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Fri, 1 Sep 2023 13:43:17 +0100 Subject: [PATCH 1/4] Adding subsetting to callPlugin function --- source/clientserver/makeRequestBlock.cpp | 2 +- source/plugins/testplugin/testplugin.cpp | 33 +++++ source/plugins/udaPlugin.cpp | 21 ++- test/plugins/test_testplugin.cpp | 168 +++++++++++++++++++---- 4 files changed, 187 insertions(+), 37 deletions(-) diff --git a/source/clientserver/makeRequestBlock.cpp b/source/clientserver/makeRequestBlock.cpp index 7047a02d..aa8295d4 100644 --- a/source/clientserver/makeRequestBlock.cpp +++ b/source/clientserver/makeRequestBlock.cpp @@ -1268,7 +1268,7 @@ int parse_element(SUBSET& subset, const std::string& element) case 1: // TODO: handle non-slice operations? i.e. [>=4], etc. subset.lbindex[index] = parse_integer(tokens[0]); - subset.ubindex[index] = { .init = false, .value = 0 }; + subset.ubindex[index] = { .init = true, .value = (subset.lbindex[index].value + 1) }; subset.stride[index] = { .init = false, .value = 0 }; break; case 2: diff --git a/source/plugins/testplugin/testplugin.cpp b/source/plugins/testplugin/testplugin.cpp index 4b45f720..eb158a28 100755 --- a/source/plugins/testplugin/testplugin.cpp +++ b/source/plugins/testplugin/testplugin.cpp @@ -132,6 +132,11 @@ static int do_scalartest(IDAM_PLUGIN_INTERFACE* plugin_interface); static int do_array1dtest(IDAM_PLUGIN_INTERFACE* plugin_interface); +static int do_call_plugin_test(IDAM_PLUGIN_INTERFACE* plugin_interface); +static int do_call_plugin_test_index(IDAM_PLUGIN_INTERFACE* plugin_interface); +static int do_call_plugin_test_slice(IDAM_PLUGIN_INTERFACE* plugin_interface); +static int do_call_plugin_test_stride(IDAM_PLUGIN_INTERFACE* plugin_interface); + static int do_emptytest(IDAM_PLUGIN_INTERFACE* plugin_interface); #ifdef CAPNP_ENABLED @@ -318,6 +323,14 @@ extern int testplugin(IDAM_PLUGIN_INTERFACE* plugin_interface) err = do_scalartest(plugin_interface); } else if (STR_IEQUALS(request->function, "array1dtest")) { err = do_array1dtest(plugin_interface); + } else if (STR_IEQUALS(request->function, "call_plugin_test")) { + err = do_call_plugin_test(plugin_interface); + } else if (STR_IEQUALS(request->function, "call_plugin_test_index")) { + err = do_call_plugin_test_index(plugin_interface); + } else if (STR_IEQUALS(request->function, "call_plugin_test_slice")) { + err = do_call_plugin_test_slice(plugin_interface); + } else if (STR_IEQUALS(request->function, "call_plugin_test_stride")) { + err = do_call_plugin_test_stride(plugin_interface); } else if (STR_IEQUALS(request->function, "emptytest")) { err = do_emptytest(plugin_interface); #ifdef TESTUDT @@ -3906,6 +3919,26 @@ int do_emptytest(IDAM_PLUGIN_INTERFACE* plugin_interface) return 0; } +int do_call_plugin_test(IDAM_PLUGIN_INTERFACE* plugin_interface) +{ + return callPlugin(plugin_interface->pluginList, "TESTPLUGIN::array1dtest()", plugin_interface); +} + +int do_call_plugin_test_index(IDAM_PLUGIN_INTERFACE* plugin_interface) +{ + return callPlugin(plugin_interface->pluginList, "TESTPLUGIN::array1dtest()[25]", plugin_interface); +} + +int do_call_plugin_test_slice(IDAM_PLUGIN_INTERFACE* plugin_interface) +{ + return callPlugin(plugin_interface->pluginList, "TESTPLUGIN::array1dtest()[10:20]", plugin_interface); +} + +int do_call_plugin_test_stride(IDAM_PLUGIN_INTERFACE* plugin_interface) +{ + return callPlugin(plugin_interface->pluginList, "TESTPLUGIN::array1dtest()[::2]", plugin_interface); +} + #ifdef CAPNP_ENABLED int do_capnp_test(IDAM_PLUGIN_INTERFACE* plugin_interface) { diff --git a/source/plugins/udaPlugin.cpp b/source/plugins/udaPlugin.cpp index 85d7a635..b973cfcd 100644 --- a/source/plugins/udaPlugin.cpp +++ b/source/plugins/udaPlugin.cpp @@ -2,6 +2,7 @@ #include "server/initPluginList.h" #include "server/serverPlugin.h" #include "structures/struct.h" +#include "server/serverSubsetData.h" #include #include @@ -632,18 +633,14 @@ int callPlugin(const PLUGINLIST* pluginlist, const char* signal, const IDAM_PLUG RAISE_PLUGIN_ERROR("Data Access is not available for this data request!"); } - // Apply subsetting -// if (request_data->datasubset.nbound > 0) { -// UDA_LOG(UDA_LOG_DEBUG, "Calling serverSubsetData (SUBSET) %d\n", *depth); -// ACTION action = {}; -// initAction(&action); -// action.actionType = UDA_SUBSET_TYPE; -// action.subset = request_data->datasubset; -// if ((rc = serverSubsetData(data_block, action, logmalloclist)) != 0) { -// (*depth)--; -// return rc; -// } -// } + // Apply subsettinng + if (request.datasubset.nbound > 0) { + ACTION action = {}; + initAction(&action); + action.actionType = UDA_SUBSET_TYPE; + action.subset = request.datasubset; + err = serverSubsetData(idam_plugin_interface.data_block, action, idam_plugin_interface.logmalloclist); + } return err; } diff --git a/test/plugins/test_testplugin.cpp b/test/plugins/test_testplugin.cpp index 52879d17..ea93bc1b 100755 --- a/test/plugins/test_testplugin.cpp +++ b/test/plugins/test_testplugin.cpp @@ -1,7 +1,6 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include #include #include @@ -161,14 +160,14 @@ TEST_CASE( "Run test2 - pass string list as 2D char array", "[plugins][TESTPLUGI std::vector vec = array->as(); std::vector strings; - strings.push_back(std::string(vec.data() + 0 * dims[0].size(), strlen(vec.data() + 0 * dims[0].size()))); - strings.push_back(std::string(vec.data() + 1 * dims[0].size(), strlen(vec.data() + 1 * dims[0].size()))); - strings.push_back(std::string(vec.data() + 2 * dims[0].size(), strlen(vec.data() + 2 * dims[0].size()))); + strings.emplace_back(std::string(vec.data() + 0 * dims[0].size(), strlen(vec.data() + 0 * dims[0].size()))); + strings.emplace_back(std::string(vec.data() + 1 * dims[0].size(), strlen(vec.data() + 1 * dims[0].size()))); + strings.emplace_back(std::string(vec.data() + 2 * dims[0].size(), strlen(vec.data() + 2 * dims[0].size()))); std::vector expected; - expected.push_back("Hello World!"); - expected.push_back("Qwerty keyboard"); - expected.push_back("MAST Upgrade"); + expected.emplace_back("Hello World!"); + expected.emplace_back("Qwerty keyboard"); + expected.emplace_back("MAST Upgrade"); REQUIRE( strings == expected ); } @@ -203,9 +202,9 @@ TEST_CASE( "Run test3 - pass string list as array of strings", "[plugins][TESTPL std::vector strings = array->as(); std::vector expected; - expected.push_back("Hello World!"); - expected.push_back("Qwerty keyboard"); - expected.push_back("MAST Upgrade"); + expected.emplace_back("Hello World!"); + expected.emplace_back("Qwerty keyboard"); + expected.emplace_back("MAST Upgrade"); REQUIRE( strings == expected ); } @@ -427,11 +426,11 @@ TEST_CASE( "Run test9 - pass 4 structs containing multiple types of string array REQUIRE( child.atomicCount() == 5 ); std::vector expected_names; - expected_names.push_back("v1"); - expected_names.push_back("v2"); - expected_names.push_back("v3"); - expected_names.push_back("v4"); - expected_names.push_back("v5"); + expected_names.emplace_back("v1"); + expected_names.emplace_back("v2"); + expected_names.emplace_back("v3"); + expected_names.emplace_back("v4"); + expected_names.emplace_back("v5"); REQUIRE( child.atomicNames() == expected_names ); std::vector expected_ptrs; @@ -443,11 +442,11 @@ TEST_CASE( "Run test9 - pass 4 structs containing multiple types of string array REQUIRE( child.atomicPointers() == expected_ptrs ); std::vector expected_types; - expected_types.push_back("STRING"); - expected_types.push_back("STRING"); - expected_types.push_back("STRING"); - expected_types.push_back("STRING *"); - expected_types.push_back("STRING *"); + expected_types.emplace_back("STRING"); + expected_types.emplace_back("STRING"); + expected_types.emplace_back("STRING"); + expected_types.emplace_back("STRING *"); + expected_types.emplace_back("STRING *"); REQUIRE( child.atomicTypes() == expected_types ); std::vector expected_ranks; @@ -540,7 +539,7 @@ TEST_CASE( "Run test10 - pass single int", "[plugins][TESTPLUGIN]" ) REQUIRE( !data->isNull() ); REQUIRE( data->type().name() == typeid(int).name() ); - uda::Scalar* value = dynamic_cast(data); + auto* value = dynamic_cast(data); REQUIRE( value != nullptr ); @@ -916,7 +915,7 @@ TEST_CASE( "Run test20 - pass single short", "[plugins][TESTPLUGIN]" ) REQUIRE( !data->isNull() ); REQUIRE( data->type().name() == typeid(short).name() ); - uda::Scalar* value = dynamic_cast(data); + auto* value = dynamic_cast(data); REQUIRE( value != nullptr ); @@ -1623,7 +1622,7 @@ TEST_CASE( "Run scalartest - return a simple scalar value", "[plugins][TESTPLUGI REQUIRE( !data->isNull() ); REQUIRE( data->type().name() == typeid(int).name() ); - uda::Scalar* value = dynamic_cast(data); + auto* value = dynamic_cast(data); REQUIRE( value != nullptr ); @@ -1647,7 +1646,7 @@ TEST_CASE( "Run array1dtest - return a simple 1d array value", "[plugins][TESTPL REQUIRE( !data->isNull() ); REQUIRE( data->type().name() == typeid(double).name() ); - uda::Array* array = dynamic_cast(data); + auto* array = dynamic_cast(data); REQUIRE( array != nullptr ); @@ -1819,6 +1818,127 @@ TEST_CASE( "Test array subsetting with argument with square brackets", "[plugins REQUIRE( vec[4] == Approx(4.0) ); } +TEST_CASE( "Run call_plugin_test - return the result of calling a plugin", "[plugins][TESTPLUGIN]" ) +{ +#include "setup.inc" + + uda::Client client; + + const uda::Result& result = client.get("TESTPLUGIN::call_plugin_test()", ""); + + REQUIRE( result.errorCode() == 0 ); + REQUIRE( result.errorMessage().empty() ); + + uda::Data* data = result.data(); + + REQUIRE( data != nullptr ); + REQUIRE( !data->isNull() ); + REQUIRE( data->type().name() == typeid(double).name() ); + + auto* array = dynamic_cast(data); + + REQUIRE( array != nullptr ); + + auto vec = array->as(); + + REQUIRE( vec.size() == 100 ); + REQUIRE( vec[0] == Approx(0.0) ); + REQUIRE( vec[1] == Approx(1.0) ); + REQUIRE( vec[2] == Approx(2.0) ); + REQUIRE( vec[3] == Approx(3.0) ); + REQUIRE( vec[4] == Approx(4.0) ); +} + +TEST_CASE( "Run call_plugin_test_index - return the result of calling a plugin", "[plugins][TESTPLUGIN]" ) +{ +#include "setup.inc" + + uda::Client client; + + const uda::Result& result = client.get("TESTPLUGIN::call_plugin_test_index()", ""); + + REQUIRE( result.errorCode() == 0 ); + REQUIRE( result.errorMessage().empty() ); + + uda::Data* data = result.data(); + + REQUIRE( data != nullptr ); + REQUIRE( !data->isNull() ); + REQUIRE( data->type().name() == typeid(double).name() ); + + auto* array = dynamic_cast(data); + + REQUIRE( array != nullptr ); + + auto vec = array->as(); + + REQUIRE( vec.size() == 1 ); + REQUIRE( vec[0] == Approx(25.0) ); +} + +TEST_CASE( "Run call_plugin_test_slice - return the result of calling a plugin", "[plugins][TESTPLUGIN]" ) +{ +#include "setup.inc" + + uda::Client client; + + const uda::Result& result = client.get("TESTPLUGIN::call_plugin_test_slice()", ""); + + REQUIRE( result.errorCode() == 0 ); + REQUIRE( result.errorMessage().empty() ); + + uda::Data* data = result.data(); + + REQUIRE( data != nullptr ); + REQUIRE( !data->isNull() ); + REQUIRE( data->type().name() == typeid(double).name() ); + + auto* array = dynamic_cast(data); + + REQUIRE( array != nullptr ); + + auto vec = array->as(); + + REQUIRE( vec.size() == 10 ); + REQUIRE( vec[0] == Approx(10.0) ); + REQUIRE( vec[1] == Approx(11.0) ); + REQUIRE( vec[2] == Approx(12.0) ); + REQUIRE( vec[3] == Approx(13.0) ); + REQUIRE( vec[4] == Approx(14.0) ); +} + +// TODO: stride seems to be broken +//TEST_CASE( "Run call_plugin_test_stride - return the result of calling a plugin", "[plugins][TESTPLUGIN]" ) +//{ +//#include "setup.inc" +// +// uda::Client client; +// +// const uda::Result& result = client.get("TESTPLUGIN::call_plugin_test_stide()", ""); +// +// REQUIRE( result.errorCode() == 0 ); +// REQUIRE( result.errorMessage().empty() ); +// +// uda::Data* data = result.data(); +// +// REQUIRE( data != nullptr ); +// REQUIRE( !data->isNull() ); +// REQUIRE( data->type().name() == typeid(double).name() ); +// +// auto* array = dynamic_cast(data); +// +// REQUIRE( array != nullptr ); +// +// auto vec = array->as(); +// +// REQUIRE( vec.size() == 50 ); +// REQUIRE( vec[0] == Approx(0.0) ); +// REQUIRE( vec[1] == Approx(2.0) ); +// REQUIRE( vec[2] == Approx(4.0) ); +// REQUIRE( vec[3] == Approx(6.0) ); +// REQUIRE( vec[4] == Approx(8.0) ); +//} + TEST_CASE( "Run emptytest - return no data", "[plugins][TESTPLUGIN]" ) { #include "setup.inc" From 45e42012d0fd188e44e0ab6275b5e36d023b0238 Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 14 Sep 2023 11:31:01 +0100 Subject: [PATCH 2/4] fixing debug printing logic in idl wrapper and rpath linking in cli binary --- source/bin/CMakeLists.txt | 5 +---- source/wrappers/idl/idam_dlm.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 5a068cf6..c3488e7e 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -24,13 +24,10 @@ if( ENABLE_CAPNP ) if ( "${STDCXX_LIBRARY_FILE}" STREQUAL "" ) set ( STDCXX_RPATH "" ) else() - set ( STDCXX_RPATH "-Wl,-rpath,${STDCXX_LIBRARY_FILE} -L${STDCXX_LIBRARY_FILE} -lstdc++" ) + set ( STDCXX_RPATH "-Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} -lstdc++" ) endif() - # get_filename_component( CAPNP_LIB_CMAKE_DIR ${CapnProto_DIR} DIRECTORY ) - # get_filename_component( CAPNP_LIB_DIR ${CAPNP_LIB_CMAKE_DIR} DIRECTORY ) - if ( "${capnp_LIBRARY_DIRS}" STREQUAL "" ) set( CAPNP_RPATH "" ) else() diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index d27e786f..149f5d60 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -4297,7 +4297,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) ndata = getIdamDimNum(sin->handle, dimid); ilDims[0] = (IDL_MEMINT)ndata; - if (NDEBUG) { + if (!NDEBUG) { fprintf(stdout, "No of Elements = %d\n", (int)ilDims[0]); } @@ -4435,12 +4435,12 @@ freeidam(int argc, IDL_VPTR argv[], char* argk) handle = IDL_LongScalar(argv[0]); - if (NDEBUG) { + if (!NDEBUG) { fprintf(stdout, "Freeing IDAM data Handle %d\n", handle); } if (handle < 0) { - if (NDEBUG) { + if (!NDEBUG) { fprintf(stdout, "Not a Valid IDAM data Handle!\n"); } From af08e96cec2099da95c2f129b289c22645e9fdfb Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 14 Sep 2023 11:58:53 +0100 Subject: [PATCH 3/4] fixing typo in cli cmake --- source/bin/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index c3488e7e..647abd84 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -21,7 +21,7 @@ if( ENABLE_CAPNP ) find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) get_filename_component(STDCXX_LIBRARY_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) - if ( "${STDCXX_LIBRARY_FILE}" STREQUAL "" ) + if ( "${STDCXX_LIBRARY_DIR}" STREQUAL "" ) set ( STDCXX_RPATH "" ) else() set ( STDCXX_RPATH "-Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} -lstdc++" ) From f24db0a43b58ce3b24183a68aadc09de747216de Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Thu, 5 Oct 2023 09:36:44 +0100 Subject: [PATCH 4/4] Fixing issue with SSL enabled client. --- source/authentication/udaClientSSL.cpp | 13 ++++++--- source/authentication/udaClientSSL.h | 1 + source/bin/uda_cli.cpp | 39 +++++++++++++++++++++----- source/client/udaClient.cpp | 24 +++++++++++----- source/wrappers/c++/client.cpp | 5 ++++ source/wrappers/c++/client.hpp | 2 ++ 6 files changed, 66 insertions(+), 18 deletions(-) diff --git a/source/authentication/udaClientSSL.cpp b/source/authentication/udaClientSSL.cpp index 880d33b5..7bbf1de5 100755 --- a/source/authentication/udaClientSSL.cpp +++ b/source/authentication/udaClientSSL.cpp @@ -40,7 +40,7 @@ void putUdaClientSSLSocket(int s) g_sslSocket = s; } -void initUdaClientSSL() +static void init_ssl_library() { if (g_sslInit) { return; // Already initialised @@ -323,7 +323,7 @@ int configureUdaClientSSLContext(const HostData* host) return 0; } -int startUdaClientSSL() +int initUdaClientSSL() { // Has SSL/TLS authentication already been passed? if (g_sslOK) { @@ -356,16 +356,21 @@ int startUdaClientSSL() // Initialise - initUdaClientSSL(); + init_ssl_library(); if (!(g_ctx = createUdaClientSSLContext())) { UDA_THROW_ERROR(999, "Unable to create the SSL context!"); } - if (g_host == nullptr || configureUdaClientSSLContext(g_host) != 0) { + if (configureUdaClientSSLContext(g_host) != 0) { UDA_THROW_ERROR(999, "Unable to configure the SSL context!"); } + return 0; +} + +int startUdaClientSSL() +{ // Bind an SSL object with the socket g_ssl = SSL_new(g_ctx); diff --git a/source/authentication/udaClientSSL.h b/source/authentication/udaClientSSL.h index cc582ab4..52a88d6f 100755 --- a/source/authentication/udaClientSSL.h +++ b/source/authentication/udaClientSSL.h @@ -30,6 +30,7 @@ SSL *getUdaClientSSL(); void putUdaClientSSLSocket(int s); void closeUdaClientSSL(); void putUdaClientSSLProtocol(int specified); +int initUdaClientSSL(); int startUdaClientSSL(); int readUdaClientSSL(void* iohandle, char* buf, int count); int writeUdaClientSSL(void* iohandle, char* buf, int count); diff --git a/source/bin/uda_cli.cpp b/source/bin/uda_cli.cpp index 6705df3b..527dc621 100644 --- a/source/bin/uda_cli.cpp +++ b/source/bin/uda_cli.cpp @@ -374,24 +374,40 @@ void print_data(const uda::Data* data, int uda_type) } } +void conflicting_options(const boost::program_options::variables_map & vm, + const std::string & opt1, const std::string & opt2) +{ + if (vm.count(opt1) && !vm[opt1].defaulted() && vm.count(opt2) && !vm[opt2].defaulted()) + { + throw po::error(std::string("conflicting options '") + opt1 + "' and '" + opt2 + "'"); + } +} + int main(int argc, const char** argv) { po::options_description desc("Allowed options"); desc.add_options() - ("help", "produce help message") + ("help", po::bool_switch(), "produce help message") ("host,h", po::value()->default_value("localhost"), "server host name") ("port,p", po::value()->default_value(56565), "server port") - ("request", po::value()->required(), "request"); + ("request", po::value(), "request") + ("source", po::value()->default_value(""), "source") + ("ping", po::bool_switch(), "ping the server"); po::positional_options_description p; p.add("request", 1); po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); try { + po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); po::notify(vm); + + conflicting_options(vm, "ping", "request"); + if (!vm["ping"].as() && vm.count("request") == 0) { + throw po::error("either 'ping' or 'request' must be provided"); + } } catch (po::error& err) { - if (vm.count("help")) { + if (vm["help"].as()) { std::cout << "Usage: " << argv[0] << " [options] request\n"; std::cout << desc << "\n"; return 1; @@ -403,7 +419,7 @@ int main(int argc, const char** argv) } }; - if (vm.count("help")) { + if (vm["help"].as()) { std::cout << "Usage: " << argv[0] << " [options] request\n"; std::cout << desc << "\n"; return 1; @@ -417,7 +433,12 @@ int main(int argc, const char** argv) uda::Client::setServerPort(static_cast(vm["port"].as())); } - std::string request = vm["request"].as(); + std::string request; + if (vm["ping"].as()) { + request = "HELP::ping()"; + } else { + request = vm["request"].as(); + } if (request == "-") { std::stringstream ss; @@ -429,9 +450,11 @@ int main(int argc, const char** argv) } std::cout << "request: " << request << "\n"; + std::string source = vm["source"].as(); + uda::Client client; try { - auto& res = client.get(request, ""); + auto& res = client.get(request, source); if (res.isTree()) { print_tree(res.tree(), ""); @@ -445,6 +468,8 @@ int main(int argc, const char** argv) print_data(res.data(), res.uda_type()); } + client.close(); + } catch (uda::UDAException& err) { std::cerr << "UDA error: " << err.what() << "\n"; return -1; diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index 4ce8d76a..370ce708 100755 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -51,8 +51,8 @@ USERDEFINEDTYPELIST* g_user_defined_type_list = nullptr; // List of a LOGMALLOCLIST* g_log_malloc_list = nullptr; // List of all Heap Allocations for Data unsigned int g_last_malloc_index = 0; // Malloc Log search index last value unsigned int* g_last_malloc_index_value = &g_last_malloc_index;; // Preserve Malloc Log search index last value in GENERAL_STRUCT -XDR* g_client_input = nullptr; -XDR* g_client_output = nullptr; +XDR** g_client_input = nullptr; +XDR** g_client_output = nullptr; LOGSTRUCTLIST* g_log_struct_list = nullptr; #endif // FATCLIENT @@ -366,8 +366,8 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) static int malloc_source = UDA_MALLOC_SOURCE_NONE; #ifndef FATCLIENT - g_client_input = client_input; // needed for udaFreeAll - g_client_output = client_output; // needed for udaFreeAll + g_client_input = &client_input; // needed for udaFreeAll + g_client_output = &client_output; // needed for udaFreeAll #endif LOGSTRUCTLIST log_struct_list; @@ -517,6 +517,16 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) # endif time(&tv_server_start); // Start the Clock again: Age of Server + //------------------------------------------------------------------------- + // Connect to the server with SSL (X509) authentication + +# if defined(SSLAUTHENTICATION) && !defined(FATCLIENT) + // Create the SSL binding and context, and verify the server certificate + if ((err = initUdaClientSSL()) != 0) { + break; + } +# endif + //------------------------------------------------------------------------- // Create the XDR Record Streams std::tie(client_input, client_output) = clientCreateXDRStream(); @@ -1444,9 +1454,9 @@ void udaFreeAll() client_block.timeout = 0; // Surrogate CLOSEDOWN instruction client_block.clientFlags = client_block.clientFlags | CLIENTFLAG_CLOSEDOWN; // Direct CLOSEDOWN instruction protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; - protocol2(g_client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, + protocol2(*g_client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, protocol_version, g_log_struct_list, *udaPrivateFlags(), UDA_MALLOC_SOURCE_NONE); - xdrrec_endofrecord(g_client_output, 1); + xdrrec_endofrecord(*g_client_output, 1); } #endif // <========================== End of Client Server Code Only @@ -1455,7 +1465,7 @@ void udaFreeAll() #ifndef FATCLIENT // Close the Socket, XDR Streams and All Files - closedown(ClosedownType::CLOSE_ALL, nullptr, g_client_input, g_client_output, &reopen_logs); + closedown(ClosedownType::CLOSE_ALL, nullptr, *g_client_input, *g_client_output, &reopen_logs); #else closedown(ClosedownType::CLOSE_ALL, nullptr, nullptr, nullptr, &reopen_logs); #endif diff --git a/source/wrappers/c++/client.cpp b/source/wrappers/c++/client.cpp index a21ea557..95fba912 100755 --- a/source/wrappers/c++/client.cpp +++ b/source/wrappers/c++/client.cpp @@ -86,6 +86,11 @@ void uda::Client::setProperty(Property prop, int value) } } +void uda::Client::close() +{ + udaFreeAll(); +} + int uda::Client::property(Property prop) { auto client_flags = udaClientFlags(); diff --git a/source/wrappers/c++/client.hpp b/source/wrappers/c++/client.hpp index dad4fff3..9a036d8c 100755 --- a/source/wrappers/c++/client.hpp +++ b/source/wrappers/c++/client.hpp @@ -181,6 +181,8 @@ class LIBRARY_API Client { void put(const std::string& instruction, const uda::Array& data); + void close(); + private: friend class ResultList;