From 8bc625426dc990c1975a1752e275411adfcd24a3 Mon Sep 17 00:00:00 2001 From: Kory Draughn Date: Thu, 5 Dec 2024 14:53:47 -0500 Subject: [PATCH] [7229] Run clang-format. --- .../irods/authentication_plugin_framework.hpp | 3 +- .../irods/experimental_plugin_framework.hpp | 6 +- .../irods/irods_client_server_negotiation.hpp | 9 +- lib/core/include/irods/irods_load_plugin.hpp | 6 +- lib/core/include/irods/irods_query.hpp | 5 +- lib/core/include/irods/rodsGenQuery.h | 6 +- lib/core/src/clientLogin.cpp | 4 +- lib/core/src/getRodsEnv.cpp | 4 +- lib/core/src/irods_buffer_encryption.cpp | 9 +- lib/core/src/irods_client_negotiation.cpp | 3 +- lib/core/src/irods_default_paths.cpp | 20 +-- lib/core/src/irods_server_properties.cpp | 9 +- lib/core/src/sockComm.cpp | 20 ++- lib/hasher/src/checksum.cpp | 30 ++-- plugins/auth_legacy/src/pam.cpp | 5 +- plugins/database/src/db_plugin.cpp | 108 +++++++------- plugins/database/src/general_query_setup.cpp | 6 +- .../src/test_delay_rule_locking_api.cpp | 32 +++- plugins/network/src/ssl.cpp | 8 +- plugins/network/src/tcp.cpp | 25 ++-- .../src/irods_rule_language.cpp | 13 +- .../rule_engines/src/cpp_default_policy.cpp | 4 +- plugins/rule_engines/src/passthrough.cpp | 3 +- server/api/src/rsExecCmd.cpp | 4 +- server/api/src/rsFileChksum.cpp | 12 +- server/api/src/rsPamAuthRequest.cpp | 8 +- server/api/src/rsProcStat.cpp | 21 +-- server/core/include/irods/agent_globals.hpp | 3 +- server/core/src/initServer.cpp | 16 +- server/core/src/irods_resource_manager.cpp | 2 +- server/core/src/irods_server_negotiation.cpp | 9 +- server/core/src/irods_signal.cpp | 2 +- server/core/src/rsApiHandler.cpp | 3 +- server/delay_server/src/irodsDelayServer.cpp | 36 +++-- server/icat/src/icatHighLevelRoutines.cpp | 2 +- server/main_server/src/agent_main.cpp | 80 ++++++---- server/main_server/src/main.cpp | 138 +++++++++++------- server/re/include/irods/irods_re_plugin.hpp | 32 ++-- .../src/test_delay_rule_locking_api.cpp | 35 ++++- 39 files changed, 417 insertions(+), 324 deletions(-) diff --git a/lib/core/include/irods/authentication_plugin_framework.hpp b/lib/core/include/irods/authentication_plugin_framework.hpp index 7d2365a2fc..c019d4ee07 100644 --- a/lib/core/include/irods/authentication_plugin_framework.hpp +++ b/lib/core/include/irods/authentication_plugin_framework.hpp @@ -118,7 +118,8 @@ namespace irods::experimental::auth using plugin_type = authentication_base; std::string scheme = _scheme; - std::transform(scheme.begin(), scheme.end(), scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform( + scheme.begin(), scheme.end(), scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); const std::string name = fmt::format("irods_auth_plugin-{}_{}", scheme, _type); diff --git a/lib/core/include/irods/experimental_plugin_framework.hpp b/lib/core/include/irods/experimental_plugin_framework.hpp index 90c83dee03..92c646fd40 100644 --- a/lib/core/include/irods/experimental_plugin_framework.hpp +++ b/lib/core/include/irods/experimental_plugin_framework.hpp @@ -146,10 +146,8 @@ namespace irods::experimental::api { static auto resolve_api_plugin(const std::string& operation, const std::string& type) { std::string lower{operation}; - std::transform(lower.begin(), - lower.end(), - lower.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform( + lower.begin(), lower.end(), lower.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); base* plugin{}; auto err = irods::load_plugin( diff --git a/lib/core/include/irods/irods_client_server_negotiation.hpp b/lib/core/include/irods/irods_client_server_negotiation.hpp index 45aeb4bb9d..51ec4336f0 100644 --- a/lib/core/include/irods/irods_client_server_negotiation.hpp +++ b/lib/core/include/irods/irods_client_server_negotiation.hpp @@ -66,11 +66,10 @@ namespace irods /// =-=-=-=-=-=-=- /// @brief function which manages the TLS and Auth negotiations with the client - error client_server_negotiation_for_server( - irods::network_object_ptr, // server connection handle - std::string&, // results of negotiation - bool, // boolean indicating whether client-server negotiation is needed - RsComm&); // RsComm initialized during agent startup + error client_server_negotiation_for_server(irods::network_object_ptr, // server connection handle + std::string&, // results of negotiation + bool, // boolean indicating whether client-server negotiation is needed + RsComm&); // RsComm initialized during agent startup /// =-=-=-=-=-=-=- /// @brief function which manages the TLS and Auth negotiations with the client diff --git a/lib/core/include/irods/irods_load_plugin.hpp b/lib/core/include/irods/irods_load_plugin.hpp index ebe89b38ff..cee567ae4d 100644 --- a/lib/core/include/irods/irods_load_plugin.hpp +++ b/lib/core/include/irods/irods_load_plugin.hpp @@ -44,9 +44,9 @@ namespace irods } else { rodsEnv env; - int status = getRodsEnv( &env ); - if ( !status ) { - if ( strlen( env.irodsPluginDirectory ) > 0 ) { + int status = getRodsEnv(&env); + if (!status) { + if (strlen(env.irodsPluginDirectory) > 0) { plugin_home = env.irodsPluginDirectory; } } diff --git a/lib/core/include/irods/irods_query.hpp b/lib/core/include/irods/irods_query.hpp index ff460c4a40..c9c2f6cc04 100644 --- a/lib/core/include/irods/irods_query.hpp +++ b/lib/core/include/irods/irods_query.hpp @@ -46,10 +46,7 @@ namespace irods std::string lowered{_str}; std::transform( - lowered.begin(), - lowered.end(), - lowered.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + lowered.begin(), lowered.end(), lowered.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); if(GEN_STR == lowered) { return GENERAL; diff --git a/lib/core/include/irods/rodsGenQuery.h b/lib/core/include/irods/rodsGenQuery.h index b7420e60bf..bdbfd1dd2d 100644 --- a/lib/core/include/irods/rodsGenQuery.h +++ b/lib/core/include/irods/rodsGenQuery.h @@ -313,9 +313,9 @@ primary ordering column. #define COL_RULE_EXEC_LAST_EXE_TIME 1010 #define COL_RULE_EXEC_STATUS 1011 #define COL_RULE_EXEC_CONTEXT 1012 -#define COL_RULE_EXEC_LOCK_HOST 1013 -#define COL_RULE_EXEC_LOCK_HOST_PID 1014 -#define COL_RULE_EXEC_LOCK_TIME 1015 +#define COL_RULE_EXEC_LOCK_HOST 1013 +#define COL_RULE_EXEC_LOCK_HOST_PID 1014 +#define COL_RULE_EXEC_LOCK_TIME 1015 /* R_TOKN_MAIN */ #define COL_TOKEN_NAMESPACE 1100 diff --git a/lib/core/src/clientLogin.cpp b/lib/core/src/clientLogin.cpp index 9312915469..3adc8db14b 100644 --- a/lib/core/src/clientLogin.cpp +++ b/lib/core/src/clientLogin.cpp @@ -345,7 +345,9 @@ int clientLogin(rcComm_t* _comm, const char* _context, const char* _scheme_overr // =-=-=-=-=-=-=- // ensure scheme is lower case for comparison std::string lower_scheme = auth_scheme; - std::transform( auth_scheme.begin(), auth_scheme.end(), auth_scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(auth_scheme.begin(), auth_scheme.end(), auth_scheme.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); // =-=-=-=-=-=-=- // filter out the pam auth as it is an extra special diff --git a/lib/core/src/getRodsEnv.cpp b/lib/core/src/getRodsEnv.cpp index 5f55c56c85..0c5ca10b17 100644 --- a/lib/core/src/getRodsEnv.cpp +++ b/lib/core/src/getRodsEnv.cpp @@ -626,9 +626,7 @@ extern "C" { _env->irodsTransBufferSizeForParaTrans ); env_var = irods::KW_CFG_IRODS_PLUGIN_DIRECTORY; - capture_string_env_var( - env_var, - _env->irodsPluginDirectory ); + capture_string_env_var(env_var, _env->irodsPluginDirectory); capture_integer_env_var(irods::KW_CFG_IRODS_TCP_KEEPALIVE_INTVL_IN_SECONDS, _env->tcp_keepalive_intvl); capture_integer_env_var(irods::KW_CFG_IRODS_TCP_KEEPALIVE_PROBES, _env->tcp_keepalive_probes); diff --git a/lib/core/src/irods_buffer_encryption.cpp b/lib/core/src/irods_buffer_encryption.cpp index 5cd812f330..3ca2da7b9b 100644 --- a/lib/core/src/irods_buffer_encryption.cpp +++ b/lib/core/src/irods_buffer_encryption.cpp @@ -63,12 +63,9 @@ namespace irods { salt_size_( _salt_sz ), num_hash_rounds_( _num_rnds ), algorithm_( _algo ) { - - std::transform( - algorithm_.begin(), - algorithm_.end(), - algorithm_.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(algorithm_.begin(), algorithm_.end(), algorithm_.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); // =-=-=-=-=-=-=- // select some sane defaults diff --git a/lib/core/src/irods_client_negotiation.cpp b/lib/core/src/irods_client_negotiation.cpp index db9baf6871..0e317acea6 100644 --- a/lib/core/src/irods_client_negotiation.cpp +++ b/lib/core/src/irods_client_negotiation.cpp @@ -212,7 +212,8 @@ namespace irods /// =-=-=-=-=-=-=- /// @brief function which determines if a client/server negotiation is needed /// on the server side - bool do_client_server_negotiation_for_server(const char* _neg) { + bool do_client_server_negotiation_for_server(const char* _neg) + { // if it is set then check for our magic token which requests // the negotiation, if it is not the magic token, move on return _neg && std::string_view{_neg} == REQ_SVR_NEG; diff --git a/lib/core/src/irods_default_paths.cpp b/lib/core/src/irods_default_paths.cpp index 2ba6ee09fd..25ee83f9da 100644 --- a/lib/core/src/irods_default_paths.cpp +++ b/lib/core/src/irods_default_paths.cpp @@ -90,8 +90,8 @@ namespace irods return path.lexically_normal(); } - fs::path - get_irods_sbin_directory() { + fs::path get_irods_sbin_directory() + { fs::path install_sbindir{IRODS_DEFAULT_PATH_SBINDIR}; install_sbindir = install_sbindir.lexically_normal(); return get_irods_directory_impl(install_sbindir); @@ -105,8 +105,8 @@ namespace irods return get_irods_directory_impl(install_confdir); } - fs::path - get_irods_runstate_directory() { + fs::path get_irods_runstate_directory() + { fs::path install_runstatedir{IRODS_DEFAULT_PATH_RUNSTATEDIR}; install_runstatedir = install_runstatedir.lexically_normal(); return get_irods_directory_impl(install_runstatedir); @@ -126,18 +126,18 @@ namespace irods return get_irods_directory_impl(install_plugdir); } - fs::path - get_irods_stacktrace_directory() { + fs::path get_irods_stacktrace_directory() + { return get_irods_home_directory() / "stacktraces"; } - fs::path - get_irods_proc_directory() { + fs::path get_irods_proc_directory() + { return get_irods_home_directory() / "log/proc"; } - fs::path - get_irods_msiExecCmd_bin_directory() { + fs::path get_irods_msiExecCmd_bin_directory() + { return get_irods_home_directory() / "msiExecCmd_bin"; } } // namespace irods diff --git a/lib/core/src/irods_server_properties.cpp b/lib/core/src/irods_server_properties.cpp index 6b0cee8d2e..d7f9fe0c86 100644 --- a/lib/core/src/irods_server_properties.cpp +++ b/lib/core/src/irods_server_properties.cpp @@ -213,7 +213,8 @@ namespace irods file_path_ = _path; std::ifstream in{file_path_}; if (!in) { - THROW(FILE_OPEN_ERR, fmt::format("[{}:{}] - Failed to open configuration file [{}]", __func__, __LINE__, file_path_)); + THROW(FILE_OPEN_ERR, + fmt::format("[{}:{}] - Failed to open configuration file [{}]", __func__, __LINE__, file_path_)); } config_props_ = json::parse(in); @@ -229,7 +230,8 @@ namespace irods std::ifstream in{file_path_}; if (!in) { - THROW(FILE_OPEN_ERR, fmt::format("[{}:{}] - Failed to open configuration file [{}]", __func__, __LINE__, file_path_)); + THROW(FILE_OPEN_ERR, + fmt::format("[{}:{}] - Failed to open configuration file [{}]", __func__, __LINE__, file_path_)); } config_props_ = json::parse(in); @@ -253,7 +255,8 @@ namespace irods else { std::ifstream in{file_path_}; if (!in) { - THROW(FILE_OPEN_ERR, fmt::format("[{}:{}] - Failed to open configuration file [{}]", __func__, __LINE__, file_path_)); + THROW(FILE_OPEN_ERR, + fmt::format("[{}:{}] - Failed to open configuration file [{}]", __func__, __LINE__, file_path_)); } new_values = json::parse(in); } diff --git a/lib/core/src/sockComm.cpp b/lib/core/src/sockComm.cpp index 5d67e5471e..58f9d4df64 100644 --- a/lib/core/src/sockComm.cpp +++ b/lib/core/src/sockComm.cpp @@ -521,29 +521,27 @@ sockOpenForInConn( rsComm_t *rsComm, int *portNum, char **addr, int proto ) { /* rsAcceptConn - Server accept connection */ -int -rsAcceptConn( rsComm_t *_comm ) { - socklen_t len = sizeof( _comm->remoteAddr ); +int rsAcceptConn(rsComm_t* _comm) +{ + socklen_t len = sizeof(_comm->remoteAddr); - const int saved_socket_flags = fcntl( _comm->sock, F_GETFL ); - int status = fcntl( _comm->sock, F_SETFL, saved_socket_flags | O_NONBLOCK ); + const int saved_socket_flags = fcntl(_comm->sock, F_GETFL); + int status = fcntl(_comm->sock, F_SETFL, saved_socket_flags | O_NONBLOCK); if ( status < 0 ) { rodsLogError( LOG_NOTICE, status, "failed to set flags with nonblock on fnctl" ); } - const int newSock = accept( _comm->sock, ( struct sockaddr * ) &_comm->remoteAddr, &len ); - status = fcntl( _comm->sock, F_SETFL, saved_socket_flags ); + const int newSock = accept(_comm->sock, (struct sockaddr*) &_comm->remoteAddr, &len); + status = fcntl(_comm->sock, F_SETFL, saved_socket_flags); if ( status < 0 ) { rodsLogError( LOG_NOTICE, status, "failed to revert flags on fnctl" ); } if ( newSock < 0 ) { const int status = SYS_SOCK_ACCEPT_ERR - errno; - rodsLogError( LOG_NOTICE, status, - "rsAcceptConn: accept error for socket %d", - _comm->sock ); + rodsLogError(LOG_NOTICE, status, "rsAcceptConn: accept error for socket %d", _comm->sock); return newSock; } - rodsSetSockOpt( newSock, _comm->windowSize ); + rodsSetSockOpt(newSock, _comm->windowSize); return newSock; } diff --git a/lib/hasher/src/checksum.cpp b/lib/hasher/src/checksum.cpp index 7e8c5e43bf..7a526ebdd3 100644 --- a/lib/hasher/src/checksum.cpp +++ b/lib/hasher/src/checksum.cpp @@ -56,11 +56,9 @@ int chksumLocFile( env_policy = env.rodsMatchHashPolicy; // =-=-=-=-=-=-=- // hash scheme keywords are all lowercase - std::transform( - env_scheme.begin(), - env_scheme.end(), - env_scheme.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(env_scheme.begin(), env_scheme.end(), env_scheme.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); } // =-=-=-=-=-=-=- @@ -72,11 +70,9 @@ int chksumLocFile( hash_scheme = _hash_scheme; // =-=-=-=-=-=-=- // hash scheme keywords are all lowercase - std::transform( - hash_scheme.begin(), - hash_scheme.end(), - hash_scheme.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); } else { hash_scheme = env_scheme; @@ -85,17 +81,11 @@ int chksumLocFile( // =-=-=-=-=-=-=- // hash scheme keywords are all lowercase + std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); std::transform( - hash_scheme.begin(), - hash_scheme.end(), - hash_scheme.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); - std::transform( - env_scheme.begin(), - env_scheme.end(), - env_scheme.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); - + env_scheme.begin(), env_scheme.end(), env_scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); // =-=-=-=-=-=-=- // verify checksum scheme against configuration diff --git a/plugins/auth_legacy/src/pam.cpp b/plugins/auth_legacy/src/pam.cpp index 8d8046a990..81c965e5fe 100644 --- a/plugins/auth_legacy/src/pam.cpp +++ b/plugins/auth_legacy/src/pam.cpp @@ -284,7 +284,10 @@ int run_pam_auth_check( } close( p2cp[1] ); const auto binary = irods::get_irods_sbin_directory() / "irodsPamAuthCheck"; - i = execl(binary.c_str(), binary.c_str(), _username.c_str(), static_cast(nullptr)); // NOLINT(cppcoreguidelines-pro-type-vararg) + i = execl(binary.c_str(), + binary.c_str(), + _username.c_str(), + static_cast(nullptr)); // NOLINT(cppcoreguidelines-pro-type-vararg) perror( "execl" ); printf( "execl failed %d\n", i ); } diff --git a/plugins/database/src/db_plugin.cpp b/plugins/database/src/db_plugin.cpp index 9149b494b5..1ea9c3cbde 100644 --- a/plugins/database/src/db_plugin.cpp +++ b/plugins/database/src/db_plugin.cpp @@ -2023,11 +2023,7 @@ irods::error db_debug_op( // =-=-=-=-=-=-=- // run tolower on mode std::string mode( _mode ); - std::transform( - mode.begin(), - mode.end(), - mode.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(mode.begin(), mode.end(), mode.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); // =-=-=-=-=-=-=- // if mode contains 'sql' then turn SQL logging on @@ -3604,47 +3600,43 @@ irods::error db_mod_rule_exec_op( /* regParamNames has the argument names (in regParam) that this routine understands and colNames has the corresponding column names; one for one. */ - char *regParamNames[] = { - RULE_NAME_KW, - RULE_REI_FILE_PATH_KW, - RULE_USER_NAME_KW, - RULE_EXE_ADDRESS_KW, - RULE_EXE_TIME_KW, - RULE_EXE_FREQUENCY_KW, - RULE_PRIORITY_KW, - RULE_ESTIMATE_EXE_TIME_KW, - RULE_NOTIFICATION_ADDR_KW, - RULE_LAST_EXE_TIME_KW, - RULE_EXE_STATUS_KW, - RULE_EXECUTION_CONTEXT_KW, - RULE_LOCK_HOST_KW, - RULE_LOCK_HOST_PID_KW, - RULE_LOCK_TIME_KW, - "END" - }; - - char *colNames[] = { - "rule_name", - "rei_file_path", - "user_name", - "exe_address", - "exe_time", - "exe_frequency", - "priority", - "estimated_exe_time", - "notification_addr", - "last_exe_time", - "exe_status", - "exe_context", - "lock_host", - "lock_host_pid", - "lock_ts", - - // The following columns are handled automatically. - // ** New columns MUST be added before these lines! ** - "create_ts", - "modify_ts" - }; + char* regParamNames[] = {RULE_NAME_KW, + RULE_REI_FILE_PATH_KW, + RULE_USER_NAME_KW, + RULE_EXE_ADDRESS_KW, + RULE_EXE_TIME_KW, + RULE_EXE_FREQUENCY_KW, + RULE_PRIORITY_KW, + RULE_ESTIMATE_EXE_TIME_KW, + RULE_NOTIFICATION_ADDR_KW, + RULE_LAST_EXE_TIME_KW, + RULE_EXE_STATUS_KW, + RULE_EXECUTION_CONTEXT_KW, + RULE_LOCK_HOST_KW, + RULE_LOCK_HOST_PID_KW, + RULE_LOCK_TIME_KW, + "END"}; + + char* colNames[] = {"rule_name", + "rei_file_path", + "user_name", + "exe_address", + "exe_time", + "exe_frequency", + "priority", + "estimated_exe_time", + "notification_addr", + "last_exe_time", + "exe_status", + "exe_context", + "lock_host", + "lock_host_pid", + "lock_ts", + + // The following columns are handled automatically. + // ** New columns MUST be added before these lines! ** + "create_ts", + "modify_ts"}; if ( logSQL != 0 ) { log_sql::debug("chlModRuleExec"); @@ -15889,10 +15881,8 @@ auto db_execute_genquery2_sql(irods::plugin_context& _ctx, } } // db_execute_genquery2_sql -auto db_delay_rule_lock(irods::plugin_context& _ctx, - const char* _rule_id, - const char* _lock_host, - int _lock_host_pid) -> irods::error +auto db_delay_rule_lock(irods::plugin_context& _ctx, const char* _rule_id, const char* _lock_host, int _lock_host_pid) + -> irods::error { if (const auto ret = _ctx.valid(); !ret.ok()) { return PASS(ret); @@ -15907,8 +15897,9 @@ auto db_delay_rule_lock(irods::plugin_context& _ctx, auto [db_instance, db_conn] = irods::experimental::catalog::new_database_connection(); nanodbc::statement stmt{db_conn}; - nanodbc::prepare(stmt, "update R_RULE_EXEC set lock_host = ?, lock_host_pid = ?, lock_ts = ? " - "where rule_exec_id = ? and lock_host = '' and lock_host_pid = '' and lock_ts = ''"); + nanodbc::prepare(stmt, + "update R_RULE_EXEC set lock_host = ?, lock_host_pid = ?, lock_ts = ? " + "where rule_exec_id = ? and lock_host = '' and lock_host_pid = '' and lock_ts = ''"); stmt.bind(0, _lock_host); stmt.bind(1, &_lock_host_pid); @@ -15919,7 +15910,11 @@ auto db_delay_rule_lock(irods::plugin_context& _ctx, stmt.bind(3, _rule_id); if (const auto result = nanodbc::execute(stmt); result.affected_rows() != 1) { - auto msg = fmt::format("{}: Failed to lock delay rule [rule_id={}, lock_host={}, lock_host_pid={}].", __func__, _rule_id, _lock_host, _lock_host_pid); + auto msg = fmt::format("{}: Failed to lock delay rule [rule_id={}, lock_host={}, lock_host_pid={}].", + __func__, + _rule_id, + _lock_host, + _lock_host_pid); log_db::error(msg); return ERROR(CAT_NO_ROWS_UPDATED, std::move(msg)); } @@ -15954,7 +15949,9 @@ auto db_delay_rule_unlock(irods::plugin_context& _ctx, const char* _rule_ids) -> nanodbc::transaction trans{db_conn}; nanodbc::statement stmt{db_conn}; - nanodbc::prepare(stmt, "update R_RULE_EXEC set lock_host = '', lock_host_pid = '', lock_ts = '', modify_ts = ? where rule_exec_id = ?"); + nanodbc::prepare(stmt, + "update R_RULE_EXEC set lock_host = '', lock_host_pid = '', lock_ts = '', modify_ts = ? where " + "rule_exec_id = ?"); // Putting this in the loop would enable finer granularity in the update sequence, but // there's likely no major benefit to it. At the very least, computing the time once @@ -16406,8 +16403,7 @@ irods::database* plugin_factory( DATABASE_OP_DELAY_RULE_LOCK, function(db_delay_rule_lock)); pg->add_operation( - DATABASE_OP_DELAY_RULE_UNLOCK, - function(db_delay_rule_unlock)); + DATABASE_OP_DELAY_RULE_UNLOCK, function(db_delay_rule_unlock)); return pg; } // plugin_factory diff --git a/plugins/database/src/general_query_setup.cpp b/plugins/database/src/general_query_setup.cpp index cbcbc89192..b9b5dfcce4 100644 --- a/plugins/database/src/general_query_setup.cpp +++ b/plugins/database/src/general_query_setup.cpp @@ -372,9 +372,9 @@ icatGeneralQuerySetup() { sColumn( COL_RULE_EXEC_LAST_EXE_TIME, "R_RULE_EXEC", "last_exe_time" ); sColumn( COL_RULE_EXEC_STATUS, "R_RULE_EXEC", "exe_status" ); sColumn( COL_RULE_EXEC_CONTEXT, "R_RULE_EXEC", "exe_context" ); - sColumn( COL_RULE_EXEC_LOCK_HOST, "R_RULE_EXEC", "lock_host" ); - sColumn( COL_RULE_EXEC_LOCK_HOST_PID, "R_RULE_EXEC", "lock_host_pid" ); - sColumn( COL_RULE_EXEC_LOCK_TIME, "R_RULE_EXEC", "lock_ts" ); + sColumn(COL_RULE_EXEC_LOCK_HOST, "R_RULE_EXEC", "lock_host"); + sColumn(COL_RULE_EXEC_LOCK_HOST_PID, "R_RULE_EXEC", "lock_host_pid"); + sColumn(COL_RULE_EXEC_LOCK_TIME, "R_RULE_EXEC", "lock_ts"); sColumn( COL_TOKEN_NAMESPACE, "R_TOKN_MAIN", "token_namespace" ); sColumn( COL_TOKEN_ID, "R_TOKN_MAIN", "token_id" ); diff --git a/plugins/microservices/src/test_delay_rule_locking_api.cpp b/plugins/microservices/src/test_delay_rule_locking_api.cpp index 605723b773..04e194f1ef 100644 --- a/plugins/microservices/src/test_delay_rule_locking_api.cpp +++ b/plugins/microservices/src/test_delay_rule_locking_api.cpp @@ -36,7 +36,11 @@ namespace auto create_delay_rule(const std::string& _rule) -> int { // NOLINTNEXTLINE(cert-env33-c) - return std::system(fmt::format(R"___(irule -r irods_rule_engine_plugin-irods_rule_language-instance 'delay("100000") {{ {} }}' null null)___", _rule).c_str()); + return std::system( + fmt::format( + R"___(irule -r irods_rule_engine_plugin-irods_rule_language-instance 'delay("100000") {{ {} }}' null null)___", + _rule) + .c_str()); } // create_delay_rule // NOLINTNEXTLINE(readability-function-cognitive-complexity) @@ -89,7 +93,9 @@ namespace { // Show the delay rule is now locked using GenQuery1. - const auto query_string = fmt::format("select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format( + "select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{_rei->rsComm, query_string}; IRODS_MSI_ASSERT(!query.empty()); const auto row = query.front(); @@ -100,7 +106,10 @@ namespace // Show the delay rule is now locked using GenQuery2. Genquery2Input input{}; irods::at_scope_exit_unsafe free_gq2_string{[&input] { clearGenquery2Input(&input); }}; - input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", rule_id).c_str()); + input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, " + "DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", + rule_id) + .c_str()); char* output{}; // NOLINTNEXTLINE(cppcoreguidelines-owning-memory, cppcoreguidelines-no-malloc) @@ -122,7 +131,9 @@ namespace { // Show the delay rule is now unlocked using GenQuery1. - const auto query_string = fmt::format("select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format( + "select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{_rei->rsComm, query_string}; IRODS_MSI_ASSERT(!query.empty()); const auto row = query.front(); @@ -133,7 +144,10 @@ namespace // Show the delay rule is now unlocked using GenQuery2. Genquery2Input input{}; irods::at_scope_exit_unsafe free_gq2_string{[&input] { clearGenquery2Input(&input); }}; - input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", rule_id).c_str()); + input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, " + "DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", + rule_id) + .c_str()); char* output{}; // NOLINTNEXTLINE(cppcoreguidelines-owning-memory, cppcoreguidelines-no-malloc) @@ -188,7 +202,9 @@ namespace // Show the delay rules are now locked. for (auto&& rule_id : rule_ids) { - const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, " + "RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{_rei->rsComm, query_string}; IRODS_MSI_ASSERT(!query.empty()); const auto row = query.front(); @@ -206,7 +222,9 @@ namespace // Show the delay rules are now unlocked. for (auto&& rule_id : rule_ids) { - const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, " + "RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{_rei->rsComm, query_string}; IRODS_MSI_ASSERT(!query.empty()); const auto row = query.front(); diff --git a/plugins/network/src/ssl.cpp b/plugins/network/src/ssl.cpp index 81e7460d95..206856de01 100644 --- a/plugins/network/src/ssl.cpp +++ b/plugins/network/src/ssl.cpp @@ -376,9 +376,11 @@ irods::error ssl_socket_read( } fd_set set; + // clang-format off struct timeval timeout{}; + // clang-format on int len_to_read = _length; - char* read_ptr = static_cast( _buffer ); + char* read_ptr = static_cast(_buffer); _bytes_read = 0; irods::error result = SUCCESS(); @@ -398,7 +400,7 @@ irods::error ssl_socket_read( result = ERROR(_length - len_to_read, "failed to read requested number of bytes"); } else { - result = ERROR(SYS_SOCK_READ_TIMEDOUT, "socket timeout error"); + result = ERROR(SYS_SOCK_READ_TIMEDOUT, "socket timeout error"); } } else if ( status < 0 ) { @@ -429,7 +431,7 @@ irods::error ssl_socket_read( // all has gone well, do byte book keeping len_to_read -= num_bytes; - read_ptr += num_bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + read_ptr += num_bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) _bytes_read += num_bytes; } // while diff --git a/plugins/network/src/tcp.cpp b/plugins/network/src/tcp.cpp index 24e3b79f5f..9aef3c4b2d 100644 --- a/plugins/network/src/tcp.cpp +++ b/plugins/network/src/tcp.cpp @@ -19,17 +19,14 @@ // =-=-=-=-=-=-=- // local function to read a buffer from a socket -irods::error tcp_socket_read( - int _socket, - void* _buffer, - int _length, - int& _bytes_read, - struct timeval* _time_value ) +irods::error tcp_socket_read(int _socket, void* _buffer, int _length, int& _bytes_read, struct timeval* _time_value) { fd_set set; + // clang-format off struct timeval timeout{}; + // clang-format on int len_to_read = _length; - char* read_ptr = static_cast( _buffer ); + char* read_ptr = static_cast(_buffer); _bytes_read = 0; while ( len_to_read > 0 ) { @@ -39,18 +36,19 @@ irods::error tcp_socket_read( FD_SET(_socket, &set); // NOLINT timeout = *_time_value; - const int status = select( _socket + 1, &set, nullptr, nullptr, &timeout ); + const int status = select(_socket + 1, &set, nullptr, nullptr, &timeout); if ( status == 0 ) { // the select has timed out - return ERROR( SYS_SOCK_READ_TIMEDOUT, fmt::format("socket timeout with [{}] bytes read", _bytes_read)); + return ERROR(SYS_SOCK_READ_TIMEDOUT, fmt::format("socket timeout with [{}] bytes read", _bytes_read)); } - if ( status < 0 ) { + if (status < 0) { if ( errno == EINTR ) { return ERROR(INTERRUPT_DETECTED, fmt::format("{} interrupted by signal", __func__)); } - return ERROR( SYS_SOCK_READ_ERR - errno, fmt::format("error on select after [{}] bytes read", _bytes_read)); + return ERROR( + SYS_SOCK_READ_ERR - errno, fmt::format("error on select after [{}] bytes read", _bytes_read)); } // else } // if tv @@ -60,14 +58,15 @@ irods::error tcp_socket_read( errno = 0; num_bytes = 0; } else { - return ERROR(SYS_SOCK_READ_ERR - errno, fmt::format("error reading from socket after [{}] bytes read", _bytes_read)); + return ERROR(SYS_SOCK_READ_ERR - errno, + fmt::format("error reading from socket after [{}] bytes read", _bytes_read)); } } else if ( num_bytes == 0 ) { break; } len_to_read -= num_bytes; - read_ptr += num_bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + read_ptr += num_bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) _bytes_read += num_bytes; } // while diff --git a/plugins/rule_engines/irods_rule_language/src/irods_rule_language.cpp b/plugins/rule_engines/irods_rule_language/src/irods_rule_language.cpp index f90691238e..bf84b80ba9 100644 --- a/plugins/rule_engines/irods_rule_language/src/irods_rule_language.cpp +++ b/plugins/rule_engines/irods_rule_language/src/irods_rule_language.cpp @@ -412,16 +412,12 @@ irods::error exec_rule_expression( return SUCCESS(); } - -extern "C" -irods::pluggable_rule_engine* plugin_factory( const std::string& _inst_name, - const std::string& _context ) +extern "C" irods::pluggable_rule_engine* plugin_factory(const std::string& _inst_name, + const std::string& _context) { - const auto no_op = [](irods::default_re_ctx&, const std::string&) -> irods::error { - return SUCCESS(); - }; + const auto no_op = [](irods::default_re_ctx&, const std::string&) -> irods::error { return SUCCESS(); }; - auto* re = new irods::pluggable_rule_engine( _inst_name , _context); + auto* re = new irods::pluggable_rule_engine(_inst_name, _context); re->add_operation("setup", std::function{setup}); re->add_operation("teardown", std::function{no_op}); @@ -445,5 +441,4 @@ irods::pluggable_rule_engine* plugin_factory( const std:: std::function( exec_rule_expression ) ); return re; - } diff --git a/plugins/rule_engines/src/cpp_default_policy.cpp b/plugins/rule_engines/src/cpp_default_policy.cpp index b63f4dfc26..d2a6e959a4 100644 --- a/plugins/rule_engines/src/cpp_default_policy.cpp +++ b/plugins/rule_engines/src/cpp_default_policy.cpp @@ -1172,9 +1172,7 @@ irods::pluggable_rule_engine* plugin_factory( const std:: const std::string& _context ) { irods::pluggable_rule_engine* re = new irods::pluggable_rule_engine( _inst_name , _context); - const auto no_op = [](irods::default_re_ctx&, const std::string&) -> irods::error { - return SUCCESS(); - }; + const auto no_op = [](irods::default_re_ctx&, const std::string&) -> irods::error { return SUCCESS(); }; re->add_operation("setup", std::function{no_op}); re->add_operation("teardown", std::function{no_op}); diff --git a/plugins/rule_engines/src/passthrough.cpp b/plugins/rule_engines/src/passthrough.cpp index d4cfa5a175..628e13e890 100644 --- a/plugins/rule_engines/src/passthrough.cpp +++ b/plugins/rule_engines/src/passthrough.cpp @@ -159,8 +159,7 @@ pluggable_rule_engine* plugin_factory(const std::string& _instance_name, const auto exec_rule_wrapper = [_instance_name](irods::default_re_ctx& _ctx, const std::string& _rule_name, std::list& _rule_arguments, - irods::callback _effect_handler) - { + irods::callback _effect_handler) { // NOLINTNEXTLINE(performance-unnecessary-value-param) return exec_rule(_instance_name, _ctx, _rule_name, _rule_arguments, _effect_handler); }; diff --git a/server/api/src/rsExecCmd.cpp b/server/api/src/rsExecCmd.cpp index 143cf9ee8c..b938d7c9d9 100644 --- a/server/api/src/rsExecCmd.cpp +++ b/server/api/src/rsExecCmd.cpp @@ -18,9 +18,9 @@ #include #ifndef windows_platform -#include +# include #else -#include "irods/Unix2Nt.hpp" +# include "irods/Unix2Nt.hpp" #endif #include diff --git a/server/api/src/rsFileChksum.cpp b/server/api/src/rsFileChksum.cpp index 0cf0283c5d..5e23b7635b 100644 --- a/server/api/src/rsFileChksum.cpp +++ b/server/api/src/rsFileChksum.cpp @@ -129,11 +129,9 @@ int fileChksum(rsComm_t* rsComm, } catch ( const irods::exception& ) {} // make sure the read parameter is lowercased - std::transform( - hash_scheme.begin(), - hash_scheme.end(), - hash_scheme.begin(), - [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); std::string hash_policy; try { @@ -303,7 +301,9 @@ int file_checksum(RsComm* _comm, catch (const irods::exception&) {} // Make sure the read parameter is lowercased. - std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), [](unsigned char _ch) { + return std::tolower(_ch); + }); std::string_view hash_policy; try { diff --git a/server/api/src/rsPamAuthRequest.cpp b/server/api/src/rsPamAuthRequest.cpp index 296b41bcbd..6fef91e468 100644 --- a/server/api/src/rsPamAuthRequest.cpp +++ b/server/api/src/rsPamAuthRequest.cpp @@ -86,7 +86,8 @@ runPamAuthCheck( char *username, char *password ) { } pid = fork(); if ( pid == -1 ) { - irods::experimental::log::authentication::error("{}: fork() error: errno=[{}], username=[{}].", __func__, errno, username ? username : "nullptr"); + irods::experimental::log::authentication::error( + "{}: fork() error: errno=[{}], username=[{}].", __func__, errno, username ? username : "nullptr"); return SYS_FORK_ERROR; } @@ -112,7 +113,10 @@ runPamAuthCheck( char *username, char *password ) { } close( p2cp[1] ); const auto binary = irods::get_irods_sbin_directory() / "irodsPamAuthCheck"; - i = execl(binary.c_str(), binary.c_str(), username, static_cast(nullptr)); // NOLINT(cppcoreguidelines-pro-type-vararg) + i = execl(binary.c_str(), + binary.c_str(), + username, + static_cast(nullptr)); // NOLINT(cppcoreguidelines-pro-type-vararg) perror( "execl" ); printf( "execl failed %d\n", i ); } diff --git a/server/api/src/rsProcStat.cpp b/server/api/src/rsProcStat.cpp index 5713ca34e2..eab3af2da3 100644 --- a/server/api/src/rsProcStat.cpp +++ b/server/api/src/rsProcStat.cpp @@ -41,7 +41,10 @@ namespace } if (procTokens.size() != 7) { - log_api::error("{}: Agent process info: [{}], number of parameters: [{}]", __func__, agent_info_path.c_str(), procTokens.size()); + log_api::error("{}: Agent process info: [{}], number of parameters: [{}]", + __func__, + agent_info_path.c_str(), + procTokens.size()); return UNIX_FILE_READ_ERR; } @@ -72,7 +75,8 @@ namespace } // readProcLog } // anonymous namespace -int rsProcStat( rsComm_t * rsComm, procStatInp_t * procStatInp, genQueryOut_t **procStatOut ) { +int rsProcStat(rsComm_t* rsComm, procStatInp_t* procStatInp, genQueryOut_t** procStatOut) +{ if (*procStatInp->rodsZone != '\0') { rodsServerHost_t* rodsServerHost = nullptr; const auto remoteFlag = getRcatHost(PRIMARY_RCAT, procStatInp->rodsZone, &rodsServerHost); @@ -82,13 +86,13 @@ int rsProcStat( rsComm_t * rsComm, procStatInp_t * procStatInp, genQueryOut_t ** } if ( rodsServerHost->localFlag == REMOTE_HOST ) { - return remoteProcStat( rsComm, procStatInp, procStatOut, rodsServerHost ); + return remoteProcStat(rsComm, procStatInp, procStatOut, rodsServerHost); } - return _rsProcStat( rsComm, procStatInp, procStatOut ); + return _rsProcStat(rsComm, procStatInp, procStatOut); } - return _rsProcStat( rsComm, procStatInp, procStatOut ); + return _rsProcStat(rsComm, procStatInp, procStatOut); } int @@ -251,14 +255,13 @@ localProcStat( procStatInp_t *procStatInp, /* loop through the directory */ namespace fs = boost::filesystem; fs::path srcDirPath(proc_dir); - if ( !fs::exists( srcDirPath ) || !fs::is_directory( srcDirPath ) ) { + if (!fs::exists(srcDirPath) || !fs::is_directory(srcDirPath)) { status = USER_INPUT_PATH_ERR - errno; - rodsLogError( LOG_ERROR, status, - "localProcStat: opendir local dir error for %s", proc_dir.c_str()); + rodsLogError(LOG_ERROR, status, "localProcStat: opendir local dir error for %s", proc_dir.c_str()); return status; } fs::directory_iterator end_itr; // default construction yields past-the-end - for ( fs::directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) { + for (fs::directory_iterator itr(srcDirPath); itr != end_itr; ++itr) { fs::path p = itr->path(); fs::path cp = p.filename(); if ( !isdigit( *cp.c_str() ) ) { diff --git a/server/core/include/irods/agent_globals.hpp b/server/core/include/irods/agent_globals.hpp index bf68027a6a..7a68ad3730 100644 --- a/server/core/include/irods/agent_globals.hpp +++ b/server/core/include/irods/agent_globals.hpp @@ -28,6 +28,7 @@ inline volatile std::sig_atomic_t g_terminate = 0; // NOLINT(cppcoreguidelines-a // // Low-level systems which need to react to stop instructions should include // this file and check this flag. -inline volatile std::sig_atomic_t g_terminate_graceful = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +inline volatile std::sig_atomic_t g_terminate_graceful = + 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) #endif // IRODS_AGENT_GLOBALS_HPP diff --git a/server/core/src/initServer.cpp b/server/core/src/initServer.cpp index 01e5ba6b3f..030366dea7 100644 --- a/server/core/src/initServer.cpp +++ b/server/core/src/initServer.cpp @@ -688,8 +688,8 @@ initRsComm( rsComm_t *rsComm ) { return 0; } -int -initRsCommWithStartupPack( rsComm_t *rsComm, startupPack_t *startupPack, bool& require_cs_neg) { +int initRsCommWithStartupPack(rsComm_t* rsComm, startupPack_t* startupPack, bool& require_cs_neg) +{ char *tmpStr; static char tmpStr2[LONG_NAME_LEN]; /* always use NATIVE_PROT as a client. e.g., server to server comm */ @@ -700,18 +700,18 @@ initRsCommWithStartupPack( rsComm_t *rsComm, startupPack_t *startupPack, bool& r rsComm->connectCnt = startupPack->connectCnt; rsComm->irodsProt = startupPack->irodsProt; rsComm->reconnFlag = startupPack->reconnFlag; - rstrcpy( rsComm->proxyUser.userName, startupPack->proxyUser, NAME_LEN ); + rstrcpy(rsComm->proxyUser.userName, startupPack->proxyUser, NAME_LEN); if ( strcmp( startupPack->proxyUser, PUBLIC_USER_NAME ) == 0 ) { rsComm->proxyUser.authInfo.authFlag = PUBLIC_USER_AUTH; } - rstrcpy( rsComm->proxyUser.rodsZone, startupPack->proxyRodsZone, NAME_LEN ); - rstrcpy( rsComm->clientUser.userName, startupPack->clientUser, NAME_LEN ); + rstrcpy(rsComm->proxyUser.rodsZone, startupPack->proxyRodsZone, NAME_LEN); + rstrcpy(rsComm->clientUser.userName, startupPack->clientUser, NAME_LEN); if ( strcmp( startupPack->clientUser, PUBLIC_USER_NAME ) == 0 ) { rsComm->clientUser.authInfo.authFlag = PUBLIC_USER_AUTH; } - rstrcpy( rsComm->clientUser.rodsZone, startupPack->clientRodsZone, NAME_LEN ); - rstrcpy( rsComm->cliVersion.relVersion, startupPack->relVersion, NAME_LEN ); - rstrcpy( rsComm->cliVersion.apiVersion, startupPack->apiVersion, NAME_LEN ); + rstrcpy(rsComm->clientUser.rodsZone, startupPack->clientRodsZone, NAME_LEN); + rstrcpy(rsComm->cliVersion.relVersion, startupPack->relVersion, NAME_LEN); + rstrcpy(rsComm->cliVersion.apiVersion, startupPack->apiVersion, NAME_LEN); std::string_view opt_str = startupPack->option; const auto pos = opt_str.find(REQ_SVR_NEG); diff --git a/server/core/src/irods_resource_manager.cpp b/server/core/src/irods_resource_manager.cpp index 2b7a23c05c..4962f02e22 100644 --- a/server/core/src/irods_resource_manager.cpp +++ b/server/core/src/irods_resource_manager.cpp @@ -128,7 +128,7 @@ namespace irods _context, ret.result()); // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - _plugin.reset(new impostor_resource("impostor_resource", "" ) ); + _plugin.reset(new impostor_resource("impostor_resource", "")); } else { return PASS( ret ); } diff --git a/server/core/src/irods_server_negotiation.cpp b/server/core/src/irods_server_negotiation.cpp index ba2c251421..a8667c9553 100644 --- a/server/core/src/irods_server_negotiation.cpp +++ b/server/core/src/irods_server_negotiation.cpp @@ -69,11 +69,10 @@ namespace irods /// =-=-=-=-=-=-=- /// @brief function which manages the TLS and Auth negotiations with the client - error client_server_negotiation_for_server( - irods::network_object_ptr _ptr, - std::string& _result, - bool _require_cs_neg, - RsComm& _comm) + error client_server_negotiation_for_server(irods::network_object_ptr _ptr, + std::string& _result, + bool _require_cs_neg, + RsComm& _comm) { // =-=-=-=-=-=-=- // manufacture an rei for the applyRule diff --git a/server/core/src/irods_signal.cpp b/server/core/src/irods_signal.cpp index 906989940e..badbb7d631 100644 --- a/server/core/src/irods_signal.cpp +++ b/server/core/src/irods_signal.cpp @@ -122,7 +122,7 @@ namespace irods action.sa_handler = stacktrace_signal_handler; constexpr const char* env_var = "IRODS_DISABLE_CRASH_SIGNAL_HANDLERS"; - const char *env_var_val = std::getenv(env_var); // NOLINT(concurrency-mt-unsafe) + const char* env_var_val = std::getenv(env_var); // NOLINT(concurrency-mt-unsafe) if (nullptr == env_var_val || (std::strncmp(env_var_val, "0", sizeof("0")) == 0)) { sigaction(SIGSEGV, &action, nullptr); sigaction(SIGABRT, &action, nullptr); diff --git a/server/core/src/rsApiHandler.cpp b/server/core/src/rsApiHandler.cpp index dced92e202..ac7819ab58 100644 --- a/server/core/src/rsApiHandler.cpp +++ b/server/core/src/rsApiHandler.cpp @@ -548,7 +548,8 @@ readAndProcClientMsg( rsComm_t * rsComm, int flags ) { if (ret.code() == INTERRUPT_DETECTED) { // Check if the agent factory requested for the agent to stop. if (g_terminate) { - log_agent::info("{}: Received instruction to shutdown. Agent is shutting down.", __func__, ret.code()); + log_agent::info( + "{}: Received instruction to shutdown. Agent is shutting down.", __func__, ret.code()); return SHUTDOWN_SEQUENCE_INITIATED; } diff --git a/server/delay_server/src/irodsDelayServer.cpp b/server/delay_server/src/irodsDelayServer.cpp index 4c587e236c..131a2cf55f 100644 --- a/server/delay_server/src/irodsDelayServer.cpp +++ b/server/delay_server/src/irodsDelayServer.cpp @@ -209,7 +209,9 @@ namespace _getRodsEnv(env); log_ds::debug("Connecting to host [{}] as proxy user [{}] on behalf of user [{}] ...", - *executor, env.rodsUserName, *_client_user); + *executor, + env.rodsUserName, + *_client_user); irods::experimental::fully_qualified_username local_admin{env.rodsUserName, env.rodsZone}; irods::experimental::fully_qualified_username user{*_client_user, env.rodsZone}; @@ -339,7 +341,10 @@ namespace const int status = rcRuleExecDel(&_comm, &rule_exec_del_inp); if (status < 0) { log_ds::error("{}:{} - rcRuleExecDel failed {} for ID {}", - __func__, __LINE__, status, rule_exec_del_inp.ruleExecId); + __func__, + __LINE__, + status, + rule_exec_del_inp.ruleExecId); } return status; }}; @@ -381,7 +386,10 @@ namespace const int status = rcRuleExecMod(&_comm, &rule_exec_mod_inp); if (status < 0) { log_ds::error("{}:{} - rcRuleExecMod failed {} for rule ID {}", - __func__, __LINE__, status, rule_exec_mod_inp.ruleId); + __func__, + __LINE__, + status, + rule_exec_mod_inp.ruleId); } if (rule_exec_mod_inp.condInput.len > 0) { @@ -391,8 +399,7 @@ namespace return status; }; - log_ds::debug("[{}:{}] - time:[{}],ef:[{}],next:[{}]", - __func__, __LINE__, current_time, ef_string, next_time); + log_ds::debug("[{}:{}] - time:[{}],ef:[{}],next:[{}]", __func__, __LINE__, current_time, ef_string, next_time); const int repeat_status = getNextRepeatTime(current_time, ef_string, next_time); switch(repeat_status) { case 0: @@ -412,7 +419,10 @@ namespace return (0 == _exec_status) ? delete_rule_exec_info() : update_rule_exec_info(true); default: log_ds::error("{}:{} - getNextRepeatTime returned unknown value {} for rule ID {}", - __func__, __LINE__, repeat_status, _inp.ruleExecId); + __func__, + __LINE__, + repeat_status, + _inp.ruleExecId); return repeat_status; } } // update_entry_for_repeat @@ -551,8 +561,8 @@ namespace log_ds::trace("Executing rule [rule_id={}].", _inp.ruleExecId); auto status = rcExecRuleExpression(&_comm, &exec_rule); if (g_terminate) { - log_ds::info("Rule [{}] completed with status [{}] but delay server was terminated.", - _inp.ruleExecId, status); + log_ds::info( + "Rule [{}] completed with status [{}] but delay server was terminated.", _inp.ruleExecId, status); } if (migrate_rule) { @@ -663,8 +673,8 @@ namespace } } catch (const std::exception& e) { - log_ds::error("Exception caught during execution of rule [{}]: [{}]", - rule_exec_submit_inp.ruleExecId, e.what()); + log_ds::error( + "Exception caught during execution of rule [{}]: [{}]", rule_exec_submit_inp.ruleExecId, e.what()); } log_ds::debug("rule [{}] complete", rule_exec_submit_inp.ruleExecId); @@ -672,7 +682,9 @@ namespace log_ds::debug("dequeueing rule [{}]", rule_exec_submit_inp.ruleExecId); queue.dequeue_rule(std::string(rule_exec_submit_inp.ruleExecId)); } - log_ds::debug("rule [{}] exists in queue: [{}]", rule_exec_submit_inp.ruleExecId, queue.contains_rule_id(rule_exec_submit_inp.ruleExecId)); + log_ds::debug("rule [{}] exists in queue: [{}]", + rule_exec_submit_inp.ruleExecId, + queue.contains_rule_id(rule_exec_submit_inp.ruleExecId)); } // execute_rule auto make_delay_queue_query_processor( @@ -848,7 +860,7 @@ int main(int _argc, char** _argv) log_ds::info("Delay server received shutdown signal."); return; } - + if (std::chrono::system_clock::now() - start_time >= allowed_sleep_time) { log_ds::debug("Delay server is awake."); return; diff --git a/server/icat/src/icatHighLevelRoutines.cpp b/server/icat/src/icatHighLevelRoutines.cpp index ad475c1840..c841e1268a 100644 --- a/server/icat/src/icatHighLevelRoutines.cpp +++ b/server/icat/src/icatHighLevelRoutines.cpp @@ -51,7 +51,7 @@ int chlDebug( // =-=-=-=-=-=-=- // run tolower on mode std::string mode( _mode ); - std::transform( mode.begin(), mode.end(), mode.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); + std::transform(mode.begin(), mode.end(), mode.begin(), [](unsigned char _ch) { return std::tolower(_ch); }); // =-=-=-=-=-=-=- // if mode contains 'sql' then turn SQL logging on diff --git a/server/main_server/src/agent_main.cpp b/server/main_server/src/agent_main.cpp index ada690cf3a..3f401d227b 100644 --- a/server/main_server/src/agent_main.cpp +++ b/server/main_server/src/agent_main.cpp @@ -203,7 +203,7 @@ auto main(int _argc, char* _argv[]) -> int // Configure the legacy rodsLog API so messages are written to the legacy log category // provided by the new logging API. rodsLogLevel(LOG_NOTICE); - rodsLogSqlReq(0); + rodsLogSqlReq(0); init_logger(getppid(), write_to_stdout, enable_test_mode); @@ -237,7 +237,8 @@ auto main(int _argc, char* _argv[]) -> int irods::get_dns_cache_eviction_age()); // Set the default value for evicting hostname cache entries. irods::set_server_property( - key_path_t{irods::KW_CFG_ADVANCED_SETTINGS, irods::KW_CFG_HOSTNAME_CACHE, irods::KW_CFG_EVICTION_AGE_IN_SECONDS}, + key_path_t{ + irods::KW_CFG_ADVANCED_SETTINGS, irods::KW_CFG_HOSTNAME_CACHE, irods::KW_CFG_EVICTION_AGE_IN_SECONDS}, irods::get_hostname_cache_eviction_age()); if (const auto res = createAndSetRECacheSalt(); !res.ok()) { @@ -271,7 +272,7 @@ auto main(int _argc, char* _argv[]) -> int } // Load server side pluggable api entries. - irods::api_entry_table& RsApiTable = irods::get_server_api_table(); + irods::api_entry_table& RsApiTable = irods::get_server_api_table(); irods::pack_entry_table& ApiPackTable = irods::get_pack_table(); if (const auto ret = irods::init_api_table(RsApiTable, ApiPackTable, false); !ret.ok()) { log_af::error("{}: init_api_table error for server: {}", __func__, ret.user_result()); @@ -290,7 +291,7 @@ auto main(int _argc, char* _argv[]) -> int irods::re_plugin_globals->global_re_mgr.call_setup_operations(); // Enter parent process main loop. - // + // // This process should never introduce threads. Everything it cares about must be handled // within the loop. This keeps things simple and straight forward. @@ -313,7 +314,7 @@ auto main(int _argc, char* _argv[]) -> int int numSock = 0; struct timeval time_out; // NOLINT(cppcoreguidelines-pro-type-member-init) - time_out.tv_sec = 0; + time_out.tv_sec = 0; time_out.tv_usec = 500 * 1000; const auto original_time_out = time_out; @@ -324,12 +325,13 @@ auto main(int _argc, char* _argv[]) -> int } if (g_terminate_graceful) { - log_af::info("{}: Received graceful shutdown instruction. Exiting agent factory select() loop.", __func__); + log_af::info( + "{}: Received graceful shutdown instruction. Exiting agent factory select() loop.", __func__); break; } // "select" modifies the timeval structure, so reset it. - time_out.tv_sec = 0; + time_out.tv_sec = 0; time_out.tv_usec = 500 * 1000; if (EINTR == errno) { @@ -374,7 +376,8 @@ auto main(int _argc, char* _argv[]) -> int return handle_client_request(newSock, std::time(nullptr)); } catch (const std::exception& e) { - log_agent::critical("{}: Exception caught in outermost scope of request handler: {}", __func__, e.what()); + log_agent::critical( + "{}: Exception caught in outermost scope of request handler: {}", __func__, e.what()); return 1; } } @@ -431,10 +434,11 @@ namespace { namespace logger = irods::experimental::log; + // clang-format off logger::agent::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_AGENT)); logger::agent_factory::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_AGENT_FACTORY)); logger::api::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_API)); - logger::authentication::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_AUTHENTICATION)); + logger::authentication::set_level( logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_AUTHENTICATION)); logger::database::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_DATABASE)); logger::genquery2::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_GENQUERY2)); logger::legacy::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_LEGACY)); @@ -443,6 +447,7 @@ namespace logger::resource::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_RESOURCE)); logger::rule_engine::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_RULE_ENGINE)); logger::sql::set_level(logger::get_level_from_config(irods::KW_CFG_LOG_LEVEL_CATEGORY_SQL)); + // clang-format on } // load_log_levels_for_loggers auto setup_signal_handlers() -> int @@ -546,7 +551,8 @@ namespace log_af::critical("createAndSetRECacheSalt: failed to set server_properties"); return ERROR(SYS_INVALID_INPUT_PARAM, e.what()); } - catch (const std::exception&) {} + catch (const std::exception&) { + } if (setenv(SP_RE_CACHE_SALT, cache_salt.c_str(), 1) != 0) { log_af::critical("createAndSetRECacheSalt: failed to set environment variable"); @@ -641,13 +647,15 @@ namespace const auto zone_name = irods::get_server_property(irods::KW_CFG_ZONE_NAME); const auto zone_user = irods::get_server_property(irods::KW_CFG_ZONE_USER); - rstrcpy( _comm.proxyUser.userName, zone_user.c_str(), NAME_LEN ); - rstrcpy( _comm.clientUser.userName, zone_user.c_str(), NAME_LEN ); - rstrcpy( _comm.proxyUser.rodsZone, zone_name.c_str(), NAME_LEN ); - rstrcpy( _comm.clientUser.rodsZone, zone_name.c_str(), NAME_LEN ); + rstrcpy(_comm.proxyUser.userName, zone_user.c_str(), NAME_LEN); + rstrcpy(_comm.clientUser.userName, zone_user.c_str(), NAME_LEN); + rstrcpy(_comm.proxyUser.rodsZone, zone_name.c_str(), NAME_LEN); + rstrcpy(_comm.clientUser.rodsZone, zone_name.c_str(), NAME_LEN); } catch (const irods::exception& e) { - log_af::error("{}: Error initializing client and proxy user in RsComm from server configuration: {}", __func__, e.client_display_what()); + log_af::error("{}: Error initializing client and proxy user in RsComm from server configuration: {}", + __func__, + e.client_display_what()); return e.code(); } @@ -656,7 +664,8 @@ namespace zone_port = irods::get_server_property(irods::KW_CFG_ZONE_PORT); } catch (const irods::exception& e) { - log_af::error("{}: Could not retrieve property from server configuration: [{}]", __func__, irods::KW_CFG_ZONE_PORT); + log_af::error( + "{}: Could not retrieve property from server configuration: [{}]", __func__, irods::KW_CFG_ZONE_PORT); return e.code(); } @@ -671,7 +680,8 @@ namespace return SYS_SOCK_LISTEN_ERR; } - log_af::info("{}: Server Release version {} - API Version {} is up", __func__, RODS_REL_VERSION, RODS_API_VERSION); + log_af::info( + "{}: Server Release version {} - API Version {} is up", __func__, RODS_REL_VERSION, RODS_API_VERSION); return 0; } // initServerMain @@ -751,7 +761,10 @@ namespace } if (constexpr auto max_svr_to_svr_connect_count = 7; startupPack->connectCnt > max_svr_to_svr_connect_count) { - log_agent::error("{}: Exceeded server-to-server connect count [count={}, max={}].", __func__, startupPack->connectCnt, max_svr_to_svr_connect_count); + log_agent::error("{}: Exceeded server-to-server connect count [count={}, max={}].", + __func__, + startupPack->connectCnt, + max_svr_to_svr_connect_count); sendVersion(net_obj, SYS_EXCEED_CONNECT_CNT, 0, nullptr, 0); mySockClose(net_obj->socket_handle()); return 0; @@ -763,7 +776,8 @@ namespace int bytes_to_send = heartbeat_length; while (bytes_to_send) { - const int bytes_sent = send(net_obj->socket_handle(), &(heartbeat[heartbeat_length - bytes_to_send]), bytes_to_send, 0); + const int bytes_sent = + send(net_obj->socket_handle(), &(heartbeat[heartbeat_length - bytes_to_send]), bytes_to_send, 0); // We do not check for 0 because it is not considered an error condition. It only means 0 // bytes were sent. As longs as we have more bytes to send and no error has occurred, we @@ -772,7 +786,8 @@ namespace const int errsav = errno; if (errsav != EINTR) { log_agent::error("{}: Socket error encountered during heartbeat; socket returned {}", - __func__, strerror(errsav)); + __func__, + strerror(errsav)); break; } } @@ -808,7 +823,7 @@ namespace rsComm.thread_ctx = static_cast(std::malloc(sizeof(thread_context))); bool require_cs_neg = false; - int status = initRsCommWithStartupPack(&rsComm, startupPack, require_cs_neg); // This version just uses the startupPack. + int status = initRsCommWithStartupPack(&rsComm, startupPack, require_cs_neg); // manufacture a network object for comms ret = irods::network_factory(&rsComm, net_obj); @@ -876,7 +891,8 @@ namespace } else { // copy negotiation results to comm for action by network objects - std::snprintf(rsComm.negotiation_results, sizeof(rsComm.negotiation_results), "%s", neg_results.c_str()); + std::snprintf( + rsComm.negotiation_results, sizeof(rsComm.negotiation_results), "%s", neg_results.c_str()); } } @@ -920,7 +936,7 @@ namespace status = agentMain(rsComm); // call initialization for network plugin as negotiated - ret = sockAgentStop( new_net_obj ); + ret = sockAgentStop(new_net_obj); if (!ret.ok()) { log_agent::error(PASS(ret).result()); cleanup_and_free_rsComm_members(); @@ -1064,7 +1080,7 @@ namespace // Connect to the catalog provider host. status = svrToSvrConnect(&_comm, rodsServerHost); - if ( status < 0 ) { + if (status < 0) { log_agent::error(ERROR(status, "svrToSvrConnect failed.").result()); return status; } @@ -1100,13 +1116,13 @@ namespace if (std::ofstream out{pid_file}; out) { out << fmt::format("{} {} {} {} {} {} {}\n", - _comm.clientUser.userName, - client_zone, - _comm.proxyUser.userName, - proxy_zone, - client_program_name, - _comm.clientAddr, - static_cast(_created_at)); + _comm.clientUser.userName, + client_zone, + _comm.proxyUser.userName, + proxy_zone, + client_program_name, + _comm.clientAddr, + static_cast(_created_at)); } else { log_agent::error("{}: Could not open file [{}] for agent/ips data.", __func__, pid_file); @@ -1171,7 +1187,7 @@ namespace } } - const auto flags = _shutting_down ? 0: WNOHANG; + const auto flags = _shutting_down ? 0 : WNOHANG; while (true) { pid = waitpid(-1, &status, flags); diff --git a/server/main_server/src/main.cpp b/server/main_server/src/main.cpp index 222d7b5109..80aa924859 100644 --- a/server/main_server/src/main.cpp +++ b/server/main_server/src/main.cpp @@ -124,9 +124,7 @@ namespace auto handle_shutdown() -> void; auto handle_shutdown_graceful() -> void; - auto set_delay_server_migration_info(RcComm& _comm, - std::string_view _leader, - std::string_view _successor) -> void; + auto set_delay_server_migration_info(RcComm& _comm, std::string_view _leader, std::string_view _successor) -> void; auto get_delay_server_leader(RcComm& _comm) -> std::optional; auto get_delay_server_successor(RcComm& _comm) -> std::optional; auto launch_agent_factory(const char* _src_func, bool _write_to_stdout, bool _enable_test_mode) -> bool; @@ -222,7 +220,7 @@ auto main(int _argc, char* _argv[]) -> int // Configure the legacy rodsLog API so messages are written to the legacy log category // provided by the new logging API. rodsLogLevel(LOG_NOTICE); - rodsLogSqlReq(0); + rodsLogSqlReq(0); init_logger(getpid(), write_to_stdout, enable_test_mode); @@ -242,7 +240,9 @@ auto main(int _argc, char* _argv[]) -> int } if (const auto [up_to_date, db_vers] = check_catalog_schema_version(); !up_to_date) { - const auto msg = fmt::format("Catalog schema version mismatch: expected [{}], found [{}] in catalog", IRODS_CATALOG_SCHEMA_VERSION, db_vers); + const auto msg = fmt::format("Catalog schema version mismatch: expected [{}], found [{}] in catalog", + IRODS_CATALOG_SCHEMA_VERSION, + db_vers); log_server::critical(msg); fmt::print(fmt::runtime(msg)); return 1; @@ -285,7 +285,7 @@ auto main(int _argc, char* _argv[]) -> int } // Enter parent process main loop. - // + // // This process should never introduce threads. Everything it cares about must be handled // within the loop. This keeps things simple and straight forward. // @@ -297,7 +297,7 @@ auto main(int _argc, char* _argv[]) -> int auto dsm_time_start = std::chrono::steady_clock::now(); // stfp = Short for stacktrace file processor - // This is used to control the frequency of the stacktrace file processing logic. + // This is used to control the frequency of the stacktrace file processing logic. auto stfp_time_start = dsm_time_start; while (true) { @@ -347,7 +347,7 @@ namespace auto print_usage() -> void { fmt::print(stderr, -R"__(irodsServer - Launch an iRODS server + R"__(irodsServer - Launch an iRODS server Usage: irodsServer [OPTION]... @@ -398,7 +398,8 @@ Environment Variables: auto print_version_info() -> void { constexpr const auto commit = std::string_view{IRODS_GIT_COMMIT}.substr(0, 7); - fmt::print("irodsServer v{}.{}.{}-{}\n", IRODS_VERSION_MAJOR, IRODS_VERSION_MINOR, IRODS_VERSION_PATCHLEVEL, commit); + fmt::print( + "irodsServer v{}.{}.{}-{}\n", IRODS_VERSION_MAJOR, IRODS_VERSION_MINOR, IRODS_VERSION_PATCHLEVEL, commit); } // print_version_info auto validate_configuration() -> bool @@ -453,7 +454,8 @@ Environment Variables: // Validate the server configuration. If that succeeds, move on to validating the // irods_environment.json file. - const auto schema_dir = irods::get_irods_home_directory() / fmt::format("configuration_schemas/v{}", IRODS_CONFIGURATION_SCHEMA_VERSION); + const auto schema_dir = irods::get_irods_home_directory() / + fmt::format("configuration_schemas/v{}", IRODS_CONFIGURATION_SCHEMA_VERSION); const auto server_config_schema = schema_dir / "server_config.json"; if (do_validate(config, server_config_schema.c_str())) { std::string env_file; @@ -494,11 +496,13 @@ Environment Variables: auto daemonize() -> void { // Become a background process. + // clang-format off switch (fork()) { case -1: _exit(1); case 0: break; default: _exit(0); } + // clang-format on // Become session leader. if (setsid() == -1) { @@ -506,11 +510,13 @@ Environment Variables: } // Make sure we aren't the session leader. + // clang-format off switch (fork()) { case -1: _exit(1); case 0: break; default: _exit(0); } + // clang-format on umask(0); @@ -602,7 +608,7 @@ Environment Variables: return 1; } } - + if (ftruncate(fd, 0) == -1) { fmt::print("Could not truncate PID file's contents.\n"); return 1; @@ -637,7 +643,9 @@ Environment Variables: if (role == irods::KW_CFG_SERVICE_ROLE_PROVIDER) { auto [db_instance, db_conn] = irods::experimental::catalog::new_database_connection(); - auto row = nanodbc::execute(db_conn, "select option_value from R_GRID_CONFIGURATION where namespace = 'database' and option_name = 'schema_version'"); + auto row = nanodbc::execute(db_conn, + "select option_value from R_GRID_CONFIGURATION where namespace = " + "'database' and option_name = 'schema_version'"); if (!row.next()) { return {false, -1}; } @@ -654,7 +662,9 @@ Environment Variables: log_server::error("{}: Could not verify catalog schema version: {}\n", __func__, e.client_display_what()); } catch (const std::exception& e) { - log_server::error("{}: Could not verify catalog schema version. Is the catalog service role defined in server_config.json?\n", __func__); + log_server::error("{}: Could not verify catalog schema version. Is the catalog service role defined in " + "server_config.json?\n", + __func__); } return {false, -1}; @@ -726,7 +736,9 @@ Environment Variables: log_server::error("{}: Could not get catalog service role: {}", __func__, e.client_display_what()); } catch (const std::exception& e) { - log_server::error("{}: Could not get catalog service role. Is the catalog service role defined in server_config.json?", __func__); + log_server::error( + "{}: Could not get catalog service role. Is the catalog service role defined in server_config.json?", + __func__); } if (irods::KW_CFG_SERVICE_ROLE_PROVIDER == role) { @@ -761,7 +773,9 @@ Environment Variables: else if (irods::KW_CFG_SERVICE_ROLE_CONSUMER == role) { // Wait for the provider to accept connections. while (true) { - log_server::debug("{}: Checking if Agent Factory is ready to accept client requests before launching the Delay Server.", __func__); + log_server::debug("{}: Checking if Agent Factory is ready to accept client requests before launching " + "the Delay Server.", + __func__); if (g_terminate) { log_server::info("{}: Received shutdown instruction. Exiting server main loop.", __func__); @@ -790,12 +804,14 @@ Environment Variables: log_server::debug("{}: Catalog Provider not ready to accept connections.", __func__); } - log_server::info("{}: Waiting for Catalog Provider to complete startup and accept connections.", __func__); + log_server::info( + "{}: Waiting for Catalog Provider to complete startup and accept connections.", __func__); std::this_thread::sleep_for(std::chrono::seconds{1}); } } else { - log_server::error("{}: Invalid catalog service role: expected [provider] or [consumer], found [{}]", __func__, role); + log_server::error( + "{}: Invalid catalog service role: expected [provider] or [consumer], found [{}]", __func__, role); } return -1; @@ -846,13 +862,12 @@ Environment Variables: irods::at_scope_exit free_output{[&output] { std::free(output); }}; if (const auto ec = rc_get_grid_configuration_value(&_comm, &input, &output); ec < 0) { - log_server::error( - "Could not retrieve delay server migration information from catalog " - "[error_code={}, namespace=delay_server, option_name=leader].", - ec); + log_server::error("Could not retrieve delay server migration information from catalog " + "[error_code={}, namespace=delay_server, option_name=leader].", + ec); return std::nullopt; } - + return output->option_value; } // get_delay_server_leader @@ -867,31 +882,27 @@ Environment Variables: irods::at_scope_exit free_output{[&output] { std::free(output); }}; if (const auto ec = rc_get_grid_configuration_value(&_comm, &input, &output); ec < 0) { - log_server::error( - "Could not retrieve delay server migration information from catalog " - "[error_code={}, namespace=delay_server, option_name=successor].", - ec); + log_server::error("Could not retrieve delay server migration information from catalog " + "[error_code={}, namespace=delay_server, option_name=successor].", + ec); return std::nullopt; } - + return output->option_value; } // get_delay_server_successor - auto set_delay_server_migration_info(RcComm& _comm, - std::string_view _leader, - std::string_view _successor) -> void + auto set_delay_server_migration_info(RcComm& _comm, std::string_view _leader, std::string_view _successor) -> void { DelayServerMigrationInput input{}; _leader.copy(input.leader, sizeof(DelayServerMigrationInput::leader) - 1); _successor.copy(input.successor, sizeof(DelayServerMigrationInput::successor) - 1); if (const auto ec = rc_set_delay_server_migration_info(&_comm, &input); ec < 0) { - log_server::error( - "Failed to set delay server migration info in R_GRID_CONFIGURATION " - "[error_code={}, leader={}, successor={}].", - ec, - _leader, - _successor); + log_server::error("Failed to set delay server migration info in R_GRID_CONFIGURATION " + "[error_code={}, leader={}, successor={}].", + ec, + _leader, + _successor); } } // set_delay_server_migration_info @@ -976,11 +987,14 @@ Environment Variables: previous_server_config = irods::server_properties::copy_configuration(); } catch (const irods::exception& e) { - log_server::error("{}: Reload error: {}. Server will continue with existing configuration.", __func__, e.client_display_what()); + log_server::error("{}: Reload error: {}. Server will continue with existing configuration.", + __func__, + e.client_display_what()); return; } catch (const std::exception& e) { - log_server::error("{}: Reload error: {}. Server will continue with existing configuration.", __func__, e.what()); + log_server::error( + "{}: Reload error: {}. Server will continue with existing configuration.", __func__, e.what()); return; } @@ -989,12 +1003,15 @@ Environment Variables: irods::server_properties::instance().reload(); } catch (const irods::exception& e) { - log_server::error("{}: Reload error: {}. Server will continue with existing configuration.", __func__, e.client_display_what()); + log_server::error("{}: Reload error: {}. Server will continue with existing configuration.", + __func__, + e.client_display_what()); irods::server_properties::instance().set_configuration(std::move(previous_server_config)); return; } catch (const std::exception& e) { - log_server::error("{}: Reload error: {}. Server will continue with existing configuration.", __func__, e.what()); + log_server::error( + "{}: Reload error: {}. Server will continue with existing configuration.", __func__, e.what()); irods::server_properties::instance().set_configuration(std::move(previous_server_config)); return; } @@ -1012,10 +1029,13 @@ Environment Variables: log_ns::set_server_hostname(irods::get_server_property(irods::KW_CFG_HOST)); } catch (const irods::exception& e) { - log_server::warn("{}: Could not update the logger's state: {}. Continuing with reload.", __func__, e.client_display_what()); + log_server::warn("{}: Could not update the logger's state: {}. Continuing with reload.", + __func__, + e.client_display_what()); } catch (const std::exception& e) { - log_server::warn("{}: Could not update the logger's state: {}. Continuing with reload.", __func__, e.what()); + log_server::warn( + "{}: Could not update the logger's state: {}. Continuing with reload.", __func__, e.what()); } // Get the host and port information from the server configuration before stopping the agent factory @@ -1075,10 +1095,16 @@ Environment Variables: break; } catch (const irods::exception& e) { - log_server::debug("{}: Unexpected error while waiting for previous agent factory to close its listening socket: {}", __func__, e.client_display_what()); + log_server::debug( + "{}: Unexpected error while waiting for previous agent factory to close its listening socket: {}", + __func__, + e.client_display_what()); } catch (const std::exception& e) { - log_server::debug("{}: Unexpected error while waiting for previous agent factory to close its listening socket: {}", __func__, e.what()); + log_server::debug( + "{}: Unexpected error while waiting for previous agent factory to close its listening socket: {}", + __func__, + e.what()); } } @@ -1167,7 +1193,9 @@ Environment Variables: const auto local_server_host = irods::get_server_property(irods::KW_CFG_HOST); if (0 == g_pid_ds) { - log_server::debug("{}: Checking if Agent Factory is ready to accept client requests before launching the Delay Server.", __func__); + log_server::debug( + "{}: Checking if Agent Factory is ready to accept client requests before launching the Delay Server.", + __func__); // Defer the launch of the delay server if the agent factory isn't listening. try { @@ -1186,7 +1214,8 @@ Environment Variables: } } - const auto migration_sleep_time_in_seconds = irods::get_advanced_setting(irods::KW_CFG_MIGRATE_DELAY_SERVER_SLEEP_TIME_IN_SECONDS); + const auto migration_sleep_time_in_seconds = + irods::get_advanced_setting(irods::KW_CFG_MIGRATE_DELAY_SERVER_SLEEP_TIME_IN_SECONDS); const auto now = std::chrono::steady_clock::now(); if (now - _time_start < std::chrono::seconds{migration_sleep_time_in_seconds}) { @@ -1244,7 +1273,8 @@ Environment Variables: // could take minutes, hours, days to complete. int status = 0; waitpid(g_pid_ds, &status, 0); - log_server::info("Delay server has completed shutdown [exit_code={}].", WEXITSTATUS(status)); + log_server::info( + "Delay server has completed shutdown [exit_code={}].", WEXITSTATUS(status)); g_pid_ds = 0; } } @@ -1277,7 +1307,8 @@ Environment Variables: auto log_stacktrace_files(std::chrono::steady_clock::time_point& _time_start) -> void { - const auto timeout = irods::get_advanced_setting(irods::KW_CFG_STACKTRACE_FILE_PROCESSOR_SLEEP_TIME_IN_SECONDS); + const auto timeout = + irods::get_advanced_setting(irods::KW_CFG_STACKTRACE_FILE_PROCESSOR_SLEEP_TIME_IN_SECONDS); const auto now = std::chrono::steady_clock::now(); if (now - _time_start < std::chrono::seconds{timeout}) { @@ -1325,11 +1356,10 @@ Environment Variables: const auto epoch_seconds = p.substr(slash_pos, first_dot_pos - slash_pos); const auto remaining_millis = p.substr(first_dot_pos + 1, last_dot_pos - (first_dot_pos + 1)); const auto pid = p.substr(last_dot_pos + 1); - log_server::trace( - "epoch seconds = [{}], remaining millis = [{}], agent pid = [{}]", - epoch_seconds, - remaining_millis, - pid); + log_server::trace("epoch seconds = [{}], remaining millis = [{}], agent pid = [{}]", + epoch_seconds, + remaining_millis, + pid); try { // Convert the epoch value to ISO8601 format. @@ -1346,6 +1376,7 @@ Environment Variables: file.close(); // 3. Write the contents of the stacktrace file to syslog. + // clang-format off irods::experimental::log::server::critical({ {"log_message", boost::stacktrace::to_string(stacktrace)}, {"stacktrace_agent_pid", pid}, @@ -1353,6 +1384,7 @@ Environment Variables: {"stacktrace_timestamp_epoch_seconds", epoch_seconds}, {"stacktrace_timestamp_epoch_milliseconds", remaining_millis} }); + // clang-format on // 4. Delete the stacktrace file. // diff --git a/server/re/include/irods/irods_re_plugin.hpp b/server/re/include/irods/irods_re_plugin.hpp index 33994e3ff3..0df394d4c0 100644 --- a/server/re/include/irods/irods_re_plugin.hpp +++ b/server/re/include/irods/irods_re_plugin.hpp @@ -198,28 +198,38 @@ namespace irods { error setup_operation(T& _in) { try { - auto fcn = boost::any_cast>(operations_["setup"]); + auto fcn = boost::any_cast>(operations_["setup"]); return fcn(_in, instance_name_); } catch (const boost::bad_any_cast& e) { - return ERROR(INVALID_ANY_CAST, fmt::format("failed to extract setup operation from instance [{}]: {}", instance_name_, e.what())); + return ERROR( + INVALID_ANY_CAST, + fmt::format("failed to extract setup operation from instance [{}]: {}", instance_name_, e.what())); } catch (const std::exception& e) { - return ERROR(PLUGIN_ERROR, fmt::format("failed to extract setup operation from instance [{}]: {}", instance_name_, e.what())); + return ERROR( + PLUGIN_ERROR, + fmt::format("failed to extract setup operation from instance [{}]: {}", instance_name_, e.what())); } } // setup_operation error teardown_operation(T& _in) { try { - auto fcn = boost::any_cast>(operations_["teardown"]); + auto fcn = boost::any_cast>(operations_["teardown"]); return fcn(_in, instance_name_); } catch (const boost::bad_any_cast& e) { - return ERROR(INVALID_ANY_CAST, fmt::format("failed to extract teardown operation from instance [{}]: {}", instance_name_, e.what())); + return ERROR( + INVALID_ANY_CAST, + fmt::format( + "failed to extract teardown operation from instance [{}]: {}", instance_name_, e.what())); } catch (const std::exception& e) { - return ERROR(PLUGIN_ERROR, fmt::format("failed to extract teardown operation from instance [{}]: {}", instance_name_, e.what())); + return ERROR( + PLUGIN_ERROR, + fmt::format( + "failed to extract teardown operation from instance [{}]: {}", instance_name_, e.what())); } } // teardown_operation @@ -448,14 +458,16 @@ namespace irods { return SUCCESS(); } - void call_setup_operations() { - std::for_each(begin(re_packs_), end(re_packs_), [](re_pack_inp &_inp) { + void call_setup_operations() + { + std::for_each(begin(re_packs_), end(re_packs_), [](re_pack_inp& _inp) { _inp.re_->setup_operation(_inp.re_ctx_); }); } - void call_teardown_operations() { - std::for_each(begin(re_packs_), end(re_packs_), [](re_pack_inp &_inp) { + void call_teardown_operations() + { + std::for_each(begin(re_packs_), end(re_packs_), [](re_pack_inp& _inp) { _inp.re_->teardown_operation(_inp.re_ctx_); }); } diff --git a/unit_tests/src/test_delay_rule_locking_api.cpp b/unit_tests/src/test_delay_rule_locking_api.cpp index 68265db831..cee217686f 100644 --- a/unit_tests/src/test_delay_rule_locking_api.cpp +++ b/unit_tests/src/test_delay_rule_locking_api.cpp @@ -78,7 +78,9 @@ TEST_CASE("lock and unlock delay rule") { // Show the delay rule is now locked using GenQuery1. - const auto query_string = fmt::format("select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format( + "select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{static_cast(conn), query_string}; REQUIRE_FALSE(query.empty()); const auto row = query.front(); @@ -89,7 +91,10 @@ TEST_CASE("lock and unlock delay rule") // Show the delay rule is now locked using GenQuery2. Genquery2Input input{}; irods::at_scope_exit_unsafe free_gq2_string{[&input] { clearGenquery2Input(&input); }}; - input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", rule_id).c_str()); + input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, " + "DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", + rule_id) + .c_str()); char* output{}; // NOLINTNEXTLINE(cppcoreguidelines-owning-memory, cppcoreguidelines-no-malloc) @@ -111,7 +116,9 @@ TEST_CASE("lock and unlock delay rule") { // Show the delay rule is now unlocked using GenQuery1. - const auto query_string = fmt::format("select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format( + "select RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{static_cast(conn), query_string}; REQUIRE_FALSE(query.empty()); const auto row = query.front(); @@ -122,7 +129,10 @@ TEST_CASE("lock and unlock delay rule") // Show the delay rule is now unlocked using GenQuery2. Genquery2Input input{}; irods::at_scope_exit_unsafe free_gq2_string{[&input] { clearGenquery2Input(&input); }}; - input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", rule_id).c_str()); + input.query_string = strdup(fmt::format("select DELAY_RULE_LOCK_HOST, DELAY_RULE_LOCK_HOST_PID, " + "DELAY_RULE_LOCK_TIME where DELAY_RULE_ID = '{}'", + rule_id) + .c_str()); char* output{}; // NOLINTNEXTLINE(cppcoreguidelines-owning-memory, cppcoreguidelines-no-malloc) @@ -165,7 +175,8 @@ TEST_CASE("unlock multiple delay rules") lock_input.lock_host_pid = getpid(); // Capture the IDs of the delay rules and lock them. - for (auto&& row : irods::query{static_cast(conn), "select RULE_EXEC_ID where RULE_EXEC_LOCK_HOST = ''"}) { + for (auto&& row : + irods::query{static_cast(conn), "select RULE_EXEC_ID where RULE_EXEC_LOCK_HOST = ''"}) { rule_ids.push_back(row[0]); // Lock the delay rule. @@ -177,7 +188,9 @@ TEST_CASE("unlock multiple delay rules") // Show the delay rules are now locked. for (auto&& rule_id : rule_ids) { - const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, " + "RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{static_cast(conn), query_string}; REQUIRE_FALSE(query.empty()); const auto row = query.front(); @@ -195,7 +208,9 @@ TEST_CASE("unlock multiple delay rules") // Show the delay rules are now unlocked. for (auto&& rule_id : rule_ids) { - const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", rule_id); + const auto query_string = fmt::format("select RULE_EXEC_ID, RULE_EXEC_LOCK_HOST, RULE_EXEC_LOCK_HOST_PID, " + "RULE_EXEC_LOCK_TIME where RULE_EXEC_ID = '{}'", + rule_id); irods::query query{static_cast(conn), query_string}; REQUIRE_FALSE(query.empty()); const auto row = query.front(); @@ -240,5 +255,9 @@ auto delete_all_delay_rules() -> int auto create_delay_rule(const std::string& _rule) -> int { // NOLINTNEXTLINE(cert-env33-c) - return std::system(fmt::format(R"___(irule -r irods_rule_engine_plugin-irods_rule_language-instance 'delay("100000") {{ {} }}' null null)___", _rule).c_str()); + return std::system( + fmt::format( + R"___(irule -r irods_rule_engine_plugin-irods_rule_language-instance 'delay("100000") {{ {} }}' null null)___", + _rule) + .c_str()); } // create_delay_rule