Skip to content
Merged
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
81 changes: 45 additions & 36 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
#include <boost/filesystem/operations.hpp>
#pragma GCC diagnostic pop

#include <irods/rodsErrorTable.h>
#include <irods/irods_default_paths.hpp>
#include <irods/irods_error.hpp>
#include <irods/irods_logger.hpp>
#include <irods/irods_ms_plugin.hpp>
#include <irods/irods_re_plugin.hpp>
#include <irods/irods_re_structs.hpp>
#include <irods/irods_re_ruleexistshelper.hpp>
#include <irods/irods_re_serialization.hpp>
#include <irods/irods_ms_plugin.hpp>
#include <irods/irods_re_structs.hpp>
#include <irods/irods_server_properties.hpp>
#include <irods/msParam.h>
#include <irods/rodsError.h>
#include <irods/rodsErrorTable.h>
#include <irods/rsExecMyRule.hpp>

#include "irods/private/re/python.hpp"
Expand Down Expand Up @@ -118,44 +119,41 @@ namespace
// Reference counter for nested python operations
static thread_local uint64_t ts_thread_refct = 0;
} //namespace python_state
}

void register_regexes_from_array(const nlohmann::json& _array, const std::string& _instance_name)
{
try {
for (const auto& elem : _array) {
try {
const auto& tmp = elem.get_ref<const std::string&>();
RuleExistsHelper::Instance()->registerRuleRegex(tmp);
// clang-format off
log_re::debug({
{"rule_engine_plugin", rule_engine_name},
{"instance_name", _instance_name},
{"regex", tmp},
});
// clang-format on
}
catch (const boost::bad_any_cast&) {
// clang-format off
log_re::error({
{"rule_engine_plugin", rule_engine_name},
{"instance_name", _instance_name},
{"log_message", "failed to cast pep_regex_to_match to string"},
});
// clang-format on
continue;
void register_regexes_from_array(const nlohmann::json& _array, const std::string& _instance_name)
{
try {
for (const auto& elem : _array) {
try {
const auto& tmp = elem.get_ref<const std::string&>();
RuleExistsHelper::Instance()->registerRuleRegex(tmp);
// clang-format off
log_re::debug({
{"rule_engine_plugin", rule_engine_name},
{"instance_name", _instance_name},
{"regex", tmp},
});
// clang-format on
}
catch (const boost::bad_any_cast&) {
// clang-format off
log_re::error({
{"rule_engine_plugin", rule_engine_name},
{"instance_name", _instance_name},
{"log_message", "failed to cast pep_regex_to_match to string"},
});
// clang-format on
continue;
}
}
}
catch (const boost::bad_any_cast&) {
std::stringstream msg;
msg << "[" << _instance_name << "] failed to any_cast a std::vector<boost::any>&";
THROW(INVALID_ANY_CAST, msg.str());
}
}
catch (const boost::bad_any_cast&) {
std::stringstream msg;
msg << "[" << _instance_name << "] failed to any_cast a std::vector<boost::any>&";
THROW(INVALID_ANY_CAST, msg.str());
}
}

namespace
{
irods::error to_irods_error_object(const bp::object& object)
{
if (bp::extract<int> result{object}; result.check()) {
Expand Down Expand Up @@ -610,6 +608,17 @@ static irods::error exec_rule(const irods::default_re_ctx&,
std::list<boost::any>& rule_arguments_cpp,
irods::callback effect_handler)
{
// Clear client-side errors for dynamic PEPs as we expect failures from the pre-PEPs to control
// access to operations. This comment and behavior come directly from the NREP.
irods::at_scope_exit clear_rerror_stack_for_dynamic_peps{[&rule_name, &effect_handler] {
if (rule_name.starts_with("pep_")) {
auto* rei = get_rei_from_effect_handler(effect_handler);
if (rei && rei->rsComm) {
freeRErrorContent(&rei->rsComm->rError);
}
}
}};

try {
std::lock_guard<std::recursive_mutex> lock{python_mutex};
python_thread_state_scope tstate;
Expand Down
Loading