Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.7.2 #12

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions source/authentication/udaClientSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void putUdaClientSSLSocket(int s)
g_sslSocket = s;
}

void initUdaClientSSL()
static void init_ssl_library()
{
if (g_sslInit) {
return; // Already initialised
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions source/authentication/udaClientSSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions source/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ 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_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()
Expand Down
39 changes: 32 additions & 7 deletions source/bin/uda_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>()->default_value("localhost"), "server host name")
("port,p", po::value<int>()->default_value(56565), "server port")
("request", po::value<std::string>()->required(), "request");
("request", po::value<std::string>(), "request")
("source", po::value<std::string>()->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<bool>() && 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<bool>()) {
std::cout << "Usage: " << argv[0] << " [options] request\n";
std::cout << desc << "\n";
return 1;
Expand All @@ -403,7 +419,7 @@ int main(int argc, const char** argv)
}
};

if (vm.count("help")) {
if (vm["help"].as<bool>()) {
std::cout << "Usage: " << argv[0] << " [options] request\n";
std::cout << desc << "\n";
return 1;
Expand All @@ -417,7 +433,12 @@ int main(int argc, const char** argv)
uda::Client::setServerPort(static_cast<int>(vm["port"].as<int>()));
}

std::string request = vm["request"].as<std::string>();
std::string request;
if (vm["ping"].as<bool>()) {
request = "HELP::ping()";
} else {
request = vm["request"].as<std::string>();
}

if (request == "-") {
std::stringstream ss;
Expand All @@ -429,9 +450,11 @@ int main(int argc, const char** argv)
}
std::cout << "request: " << request << "\n";

std::string source = vm["source"].as<std::string>();

uda::Client client;
try {
auto& res = client.get(request, "");
auto& res = client.get(request, source);

if (res.isTree()) {
print_tree(res.tree(), "");
Expand All @@ -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;
Expand Down
24 changes: 17 additions & 7 deletions source/client/udaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/clientserver/makeRequestBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
33 changes: 33 additions & 0 deletions source/plugins/testplugin/testplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
21 changes: 9 additions & 12 deletions source/plugins/udaPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "server/initPluginList.h"
#include "server/serverPlugin.h"
#include "structures/struct.h"
#include "server/serverSubsetData.h"

#include <server/getServerEnvironment.h>
#include <clientserver/makeRequestBlock.h>
Expand Down Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions source/wrappers/c++/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions source/wrappers/c++/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class LIBRARY_API Client {

void put(const std::string& instruction, const uda::Array& data);

void close();

private:
friend class ResultList;

Expand Down
6 changes: 3 additions & 3 deletions source/wrappers/idl/idam_dlm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down Expand Up @@ -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");
}

Expand Down
Loading