Format core source files
Formatted core .cc files according to current uncrustify configuration.
This commit is contained in:
@ -73,8 +73,8 @@ static inline size_t request_data_length(MHD_Connection* connection)
|
||||
|
||||
static bool modifies_data(const string& method)
|
||||
{
|
||||
return (method == MHD_HTTP_METHOD_POST || method == MHD_HTTP_METHOD_PUT
|
||||
|| method == MHD_HTTP_METHOD_DELETE || method == MHD_HTTP_METHOD_PATCH);
|
||||
return method == MHD_HTTP_METHOD_POST || method == MHD_HTTP_METHOD_PUT
|
||||
|| method == MHD_HTTP_METHOD_DELETE || method == MHD_HTTP_METHOD_PATCH;
|
||||
}
|
||||
|
||||
static void send_auth_error(MHD_Connection* connection)
|
||||
|
@ -113,27 +113,35 @@ const char* to_string(mxs_auth_state_t state)
|
||||
case MXS_AUTH_STATE_INIT:
|
||||
rval = "MXS_AUTH_STATE_INIT";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_PENDING_CONNECT:
|
||||
rval = "MXS_AUTH_STATE_PENDING_CONNECT";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_CONNECTED:
|
||||
rval = "MXS_AUTH_STATE_CONNECTED";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_MESSAGE_READ:
|
||||
rval = "MXS_AUTH_STATE_MESSAGE_READ";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_RESPONSE_SENT:
|
||||
rval = "MXS_AUTH_STATE_RESPONSE_SENT";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
rval = "MXS_AUTH_STATE_FAILED";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_HANDSHAKE_FAILED:
|
||||
rval = "MXS_AUTH_STATE_HANDSHAKE_FAILED";
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
rval = "MXS_AUTH_STATE_COMPLETE";
|
||||
break;
|
||||
|
||||
default:
|
||||
mxb_assert(!true);
|
||||
break;
|
||||
@ -141,5 +149,4 @@ const char* to_string(mxs_auth_state_t state)
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ static pcre2_code* compile_regex_string(const char* regex_string,
|
||||
uint32_t options,
|
||||
uint32_t* output_ovector_size);
|
||||
static bool duration_is_valid(const char* zValue, mxs::config::DurationUnit* pUnit);
|
||||
static bool get_seconds(const char* zName, const char* zValue, std::chrono::seconds* pSeconds);
|
||||
static bool get_seconds(const char* zName, const char* zValue, seconds* pSeconds);
|
||||
static bool get_seconds(const char* zName, const char* zValue, time_t* pSeconds);
|
||||
static bool get_milliseconds(const char* zName,
|
||||
const char* zValue,
|
||||
@ -1965,13 +1965,12 @@ uint64_t MXS_CONFIG_PARAMETER::get_size(const std::string& key) const
|
||||
return intval;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds
|
||||
MXS_CONFIG_PARAMETER::get_duration_in_ms(const std::string& key,
|
||||
milliseconds MXS_CONFIG_PARAMETER::get_duration_in_ms(const std::string& key,
|
||||
mxs::config::DurationInterpretation interpretation)
|
||||
const
|
||||
{
|
||||
string value = get_string(key);
|
||||
std::chrono::milliseconds duration {0};
|
||||
milliseconds duration {0};
|
||||
MXB_AT_DEBUG(bool rval = ) get_suffixed_duration(value.c_str(), interpretation, &duration);
|
||||
mxb_assert(rval); // When this function is called, the validity of the value should have been checked.
|
||||
return duration;
|
||||
@ -4740,7 +4739,8 @@ json_t* config_maxscale_to_json(const char* host)
|
||||
json_object_set_new(param, CN_RETAIN_LAST_STATEMENTS, json_integer(session_get_retain_last_statements()));
|
||||
json_object_set_new(param, CN_DUMP_LAST_STATEMENTS, json_string(session_get_dump_statements_str()));
|
||||
json_object_set_new(param, CN_LOAD_PERSISTED_CONFIGS, json_boolean(cnf->load_persisted_configs));
|
||||
json_object_set_new(param, CN_MAX_AUTH_ERRORS_UNTIL_BLOCK, json_integer(cnf->max_auth_errors_until_block));
|
||||
json_object_set_new(param, CN_MAX_AUTH_ERRORS_UNTIL_BLOCK,
|
||||
json_integer(cnf->max_auth_errors_until_block));
|
||||
|
||||
json_t* attr = json_object();
|
||||
time_t started = maxscale_started();
|
||||
@ -5064,7 +5064,7 @@ bool get_suffixed_size(const char* value, uint64_t* dest)
|
||||
|
||||
bool get_suffixed_duration(const char* zValue,
|
||||
mxs::config::DurationInterpretation interpretation,
|
||||
std::chrono::milliseconds* pDuration,
|
||||
milliseconds* pDuration,
|
||||
mxs::config::DurationUnit* pUnit)
|
||||
{
|
||||
if (!isdigit(*zValue))
|
||||
@ -5077,7 +5077,7 @@ bool get_suffixed_duration(const char* zValue,
|
||||
char* zEnd;
|
||||
uint64_t value = strtoll(zValue, &zEnd, 10);
|
||||
|
||||
std::chrono::milliseconds duration;
|
||||
milliseconds duration;
|
||||
mxs::config::DurationUnit unit = mxs::config::DURATION_IN_DEFAULT;
|
||||
|
||||
switch (*zEnd)
|
||||
@ -5085,7 +5085,7 @@ bool get_suffixed_duration(const char* zValue,
|
||||
case 'H':
|
||||
case 'h':
|
||||
unit = mxs::config::DURATION_IN_HOURS;
|
||||
duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::hours(value));
|
||||
duration = std::chrono::duration_cast<milliseconds>(std::chrono::hours(value));
|
||||
++zEnd;
|
||||
break;
|
||||
|
||||
@ -5094,13 +5094,13 @@ bool get_suffixed_duration(const char* zValue,
|
||||
if (*(zEnd + 1) == 's' || *(zEnd + 1) == 'S')
|
||||
{
|
||||
unit = mxs::config::DURATION_IN_MILLISECONDS;
|
||||
duration = std::chrono::milliseconds(value);
|
||||
duration = milliseconds(value);
|
||||
++zEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
unit = mxs::config::DURATION_IN_MINUTES;
|
||||
duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::minutes(value));
|
||||
duration = std::chrono::duration_cast<milliseconds>(std::chrono::minutes(value));
|
||||
}
|
||||
++zEnd;
|
||||
break;
|
||||
@ -5108,18 +5108,18 @@ bool get_suffixed_duration(const char* zValue,
|
||||
case 'S':
|
||||
case 's':
|
||||
unit = mxs::config::DURATION_IN_SECONDS;
|
||||
duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(value));
|
||||
duration = std::chrono::duration_cast<milliseconds>(seconds(value));
|
||||
++zEnd;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
if (interpretation == mxs::config::INTERPRET_AS_SECONDS)
|
||||
{
|
||||
duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(value));
|
||||
duration = std::chrono::duration_cast<milliseconds>(seconds(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
duration = std::chrono::milliseconds(value);
|
||||
duration = milliseconds(value);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -5149,7 +5149,7 @@ static bool duration_is_valid(const char* zValue, mxs::config::DurationUnit* pUn
|
||||
{
|
||||
// When the validity is checked, it does not matter how the value
|
||||
// should be interpreted, so any mxs::config::DurationInterpretation is fine.
|
||||
std::chrono::milliseconds duration;
|
||||
milliseconds duration;
|
||||
mxs::config::DurationUnit unit;
|
||||
bool valid = get_suffixed_duration(zValue, mxs::config::INTERPRET_AS_SECONDS, &duration, &unit);
|
||||
|
||||
@ -5181,12 +5181,12 @@ static void log_duration_suffix_warning(const char* zName, const char* zValue)
|
||||
"'s' (second) or 'ms' (milliseconds).", zName, zValue);
|
||||
}
|
||||
|
||||
static bool get_seconds(const char* zName, const char* zValue, std::chrono::seconds* pSeconds)
|
||||
static bool get_seconds(const char* zName, const char* zValue, seconds* pSeconds)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
mxs::config::DurationUnit unit;
|
||||
std::chrono::seconds seconds;
|
||||
seconds seconds;
|
||||
if (get_suffixed_duration(zValue, &seconds, &unit))
|
||||
{
|
||||
switch (unit)
|
||||
@ -5199,6 +5199,7 @@ static bool get_seconds(const char* zName, const char* zValue, std::chrono::seco
|
||||
|
||||
case mxs::config::DURATION_IN_DEFAULT:
|
||||
log_duration_suffix_warning(zName, zValue);
|
||||
|
||||
default:
|
||||
*pSeconds = seconds;
|
||||
valid = true;
|
||||
@ -5214,7 +5215,7 @@ static bool get_seconds(const char* zName, const char* zValue, std::chrono::seco
|
||||
|
||||
static bool get_seconds(const char* zName, const char* zValue, time_t* pSeconds)
|
||||
{
|
||||
std::chrono::seconds seconds;
|
||||
seconds seconds;
|
||||
|
||||
bool valid = get_seconds(zName, zValue, &seconds);
|
||||
|
||||
@ -5229,7 +5230,7 @@ static bool get_seconds(const char* zName, const char* zValue, time_t* pSeconds)
|
||||
static bool get_milliseconds(const char* zName,
|
||||
const char* zValue,
|
||||
const char* zDisplay_value,
|
||||
std::chrono::milliseconds* pMilliseconds)
|
||||
milliseconds* pMilliseconds)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
@ -5239,7 +5240,7 @@ static bool get_milliseconds(const char* zName,
|
||||
}
|
||||
|
||||
mxs::config::DurationUnit unit;
|
||||
std::chrono::milliseconds milliseconds;
|
||||
milliseconds milliseconds;
|
||||
if (get_suffixed_duration(zValue, &milliseconds, &unit))
|
||||
{
|
||||
if (unit == mxs::config::DURATION_IN_DEFAULT)
|
||||
@ -5263,7 +5264,7 @@ static bool get_milliseconds(const char* zName,
|
||||
const char* zDisplay_value,
|
||||
time_t* pMilliseconds)
|
||||
{
|
||||
std::chrono::milliseconds milliseconds;
|
||||
milliseconds milliseconds;
|
||||
|
||||
bool valid = get_milliseconds(zName, zValue, zDisplay_value, &milliseconds);
|
||||
|
||||
|
@ -58,7 +58,6 @@ bool is_core_param(Specification::Kind kind, const std::string& param)
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace config
|
||||
@ -791,5 +790,4 @@ std::string ParamString::to_string(value_type value) const
|
||||
ss << "\"" << value << "\"";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,8 +78,9 @@ namespace
|
||||
|
||||
static struct
|
||||
{
|
||||
DCB** all_dcbs; /** #workers sized array of pointers to DCBs where dcbs are listed. */
|
||||
bool check_timeouts; /** Should session timeouts be checked. */
|
||||
DCB** all_dcbs; /**< #workers sized array of pointers to DCBs where dcbs are listed. */
|
||||
|
||||
bool check_timeouts; /**< Should session timeouts be checked. */
|
||||
std::atomic<uint64_t> uid_generator {0};
|
||||
} this_unit;
|
||||
|
||||
@ -3171,7 +3172,8 @@ static int upstream_throttle_callback(DCB* dcb, DCB_REASON reason, void* userdat
|
||||
}
|
||||
else if (reason == DCB_REASON_LOW_WATER)
|
||||
{
|
||||
MXS_INFO("Low water mark hit for '%s'@'%s', accepting new data", client_dcb->user, client_dcb->remote);
|
||||
MXS_INFO("Low water mark hit for '%s'@'%s', accepting new data", client_dcb->user,
|
||||
client_dcb->remote);
|
||||
worker->add_fd(client_dcb->fd, poll_events, (MXB_POLL_DATA*)client_dcb);
|
||||
client_dcb->state = DCB_STATE_POLLING;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ static struct ThisUnit
|
||||
maxscale::MainWorker* pCurrent_main;
|
||||
int64_t clock_ticks;
|
||||
} this_unit;
|
||||
|
||||
}
|
||||
|
||||
namespace maxscale
|
||||
@ -211,7 +210,6 @@ bool MainWorker::inc_ticks(Worker::Call::action_t action)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@ -241,5 +239,4 @@ int64_t mxs_clock()
|
||||
{
|
||||
return mxs::MainWorker::ticks();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -453,7 +453,6 @@ const char ERR_CANNOT_MODIFY[] =
|
||||
"set/cleared manually. Status was not modified.";
|
||||
const char WRN_REQUEST_OVERWRITTEN[] =
|
||||
"Previous maintenance request was not yet read by the monitor and was overwritten.";
|
||||
|
||||
}
|
||||
|
||||
json_t* monitor_json_data(const Monitor* monitor, const char* host)
|
||||
@ -1299,7 +1298,7 @@ string Monitor::get_server_monitor(const SERVER* server)
|
||||
bool Monitor::is_admin_thread()
|
||||
{
|
||||
mxb::Worker* current = mxb::Worker::get_current();
|
||||
return (current == nullptr || current == mxs_rworker_get(MXS_RWORKER_MAIN));
|
||||
return current == nullptr || current == mxs_rworker_get(MXS_RWORKER_MAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2145,7 +2144,6 @@ void MonitorWorkerSimple::pre_loop()
|
||||
|
||||
void MonitorWorkerSimple::post_loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorWorkerSimple::pre_tick()
|
||||
@ -2337,5 +2335,4 @@ MonitorServer::~MonitorServer()
|
||||
mysql_close(con);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ private:
|
||||
};
|
||||
|
||||
ThisUnit this_unit;
|
||||
|
||||
}
|
||||
|
||||
Monitor* MonitorManager::create_monitor(const string& name, const string& module,
|
||||
@ -136,12 +135,14 @@ void MonitorManager::debug_wait_one_tick()
|
||||
if (mon->state() == MONITOR_STATE_RUNNING)
|
||||
{
|
||||
auto start = steady_clock::now();
|
||||
// A monitor may have been added in between the two foreach-calls (not if config changes are
|
||||
// A monitor may have been added in between the two foreach-calls (not
|
||||
// if config changes are
|
||||
// serialized). Check if entry exists.
|
||||
if (ticks.count(mon) > 0)
|
||||
{
|
||||
auto tick = ticks[mon];
|
||||
while (mxb::atomic::load(&mon->m_ticks) == tick && (steady_clock::now() - start < seconds(60)))
|
||||
while (mxb::atomic::load(&mon->m_ticks) == tick
|
||||
&& (steady_clock::now() - start < seconds(60)))
|
||||
{
|
||||
std::this_thread::sleep_for(milliseconds(100));
|
||||
}
|
||||
@ -269,7 +270,8 @@ void MonitorManager::monitor_list(DCB* dcb)
|
||||
|
||||
this_unit.foreach_monitor([dcb](Monitor* ptr) {
|
||||
dcb_printf(dcb, "%-20s | %s\n",
|
||||
ptr->name(), ptr->state() == MONITOR_STATE_RUNNING ? "Running" : "Stopped");
|
||||
ptr->name(),
|
||||
ptr->state() == MONITOR_STATE_RUNNING ? "Running" : "Stopped");
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -290,7 +292,7 @@ Monitor* MonitorManager::find_monitor(const char* name)
|
||||
{
|
||||
rval = ptr;
|
||||
}
|
||||
return (rval == nullptr);
|
||||
return rval == nullptr;
|
||||
});
|
||||
return rval;
|
||||
}
|
||||
|
@ -192,7 +192,8 @@ MYSQL* mxs_mysql_real_connect(MYSQL* con, SERVER* server, const char* user, cons
|
||||
if (!mysql && extra_port > 0)
|
||||
{
|
||||
mysql = mysql_real_connect(con, server->address, user, passwd, NULL, extra_port, NULL, 0);
|
||||
MXS_WARNING("Could not connect with normal port to server '%s', using extra_port", server->name());
|
||||
MXS_WARNING("Could not connect with normal port to server '%s', using extra_port",
|
||||
server->name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +389,6 @@ std::unique_ptr<mxq::QueryResult> execute_query(MYSQL* conn, const std::string&
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if defined (SS_DEBUG)
|
||||
|
@ -149,8 +149,8 @@ public:
|
||||
{
|
||||
Entry& entry = i->second;
|
||||
|
||||
if ((entry.sql_mode == this_unit.qc_sql_mode) &&
|
||||
(entry.options == this_thread.options))
|
||||
if ((entry.sql_mode == this_unit.qc_sql_mode)
|
||||
&& (entry.options == this_thread.options))
|
||||
{
|
||||
mxb_assert(this_unit.classifier);
|
||||
this_unit.classifier->qc_info_dup(entry.pInfo);
|
||||
@ -1606,7 +1606,6 @@ json_t* cache_entry_as_json(const std::string& stmt, const QC_CACHE_ENTRY& entry
|
||||
|
||||
return pSelf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<json_t> qc_cache_as_json(const char* zHost)
|
||||
|
@ -199,7 +199,8 @@ public:
|
||||
{
|
||||
// we check the systemd watchdog...
|
||||
m_owner.check_systemd_watchdog();
|
||||
} while (!m_sem_stop.timedwait(timeout));
|
||||
}
|
||||
while (!m_sem_stop.timedwait(timeout));
|
||||
// until the semaphore is actually posted, which it will be
|
||||
// once the notification should stop.
|
||||
}
|
||||
|
@ -180,7 +180,6 @@ void careful_strcpy(char* dest, size_t max_len, const std::string& source)
|
||||
// the necessary null, should the new string be shorter than the old.
|
||||
strncpy(dest, source.c_str(), new_len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Server* Server::server_alloc(const char* name, MXS_CONFIG_PARAMETER* params)
|
||||
@ -606,7 +605,8 @@ void Server::dListServers(DCB* dcb)
|
||||
have_servers = true;
|
||||
string stat = server->status_string();
|
||||
message += mxb::string_printf("%-18s | %-15s | %5d | %11d | %s\n",
|
||||
server->name(), server->address, server->port,
|
||||
server->name(), server->address,
|
||||
server->port,
|
||||
server->stats.n_current, stat.c_str());
|
||||
}
|
||||
return true;
|
||||
@ -804,7 +804,8 @@ std::unique_ptr<ResultSet> Server::getList()
|
||||
if (server->server_is_active())
|
||||
{
|
||||
string stat = server->status_string();
|
||||
set->add_row({server->name(), server->address, std::to_string(server->port),
|
||||
set->add_row({server->name(), server->address,
|
||||
std::to_string(server->port),
|
||||
std::to_string(server->stats.n_current), stat});
|
||||
}
|
||||
return true;
|
||||
|
@ -600,7 +600,8 @@ bool dcb_iter_cb(DCB* dcb, void* data)
|
||||
char buf[20];
|
||||
snprintf(buf, sizeof(buf), "%p", ses);
|
||||
|
||||
set->add_row({buf, ses->client_dcb->remote, ses->service->name(), session_state_to_string(ses->state)});
|
||||
set->add_row({buf, ses->client_dcb->remote, ses->service->name(),
|
||||
session_state_to_string(ses->state)});
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user