Format rest of the sources

This commit is contained in:
Markus Mäkelä
2019-05-09 11:31:40 +03:00
parent fbd61967a7
commit de95fcc9d6
29 changed files with 384 additions and 388 deletions

View File

@ -58,7 +58,8 @@ public:
{
TimePoint time_point;
int count;
Timestamp(TimePoint p, int c) : time_point(p)
Timestamp(TimePoint p, int c)
: time_point(p)
, count(c)
{
}

View File

@ -38,5 +38,4 @@ std::string to_binary_size(int64_t size);
* @return The result string
*/
std::string string_printf(const char* format, ...) mxb_attribute((format (printf, 1, 2)));
}

View File

@ -117,5 +117,4 @@ inline bool operator!=(const Host& l, const Host& r)
* @return True on success
*/
bool reverse_dns(const std::string& ip, std::string* output);
}

View File

@ -57,28 +57,28 @@ public:
enum
{
DEFAULT_CONNECT_TIMEOUT = 10, // @see https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
DEFAULT_TIMEOUT = 10 // @see https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
DEFAULT_CONNECT_TIMEOUT = 10, // @see https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
DEFAULT_TIMEOUT = 10 // @see https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
};
struct Config
{
int connect_timeout_s = DEFAULT_CONNECT_TIMEOUT;
int timeout_s = DEFAULT_TIMEOUT;
int timeout_s = DEFAULT_TIMEOUT;
};
struct Result
{
enum
{
ERROR = -1, // Some non-specific error occurred.
COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved.
OPERATION_TIMEDOUT = -3 // The operation timed out.
ERROR = -1, // Some non-specific error occurred.
COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved.
OPERATION_TIMEDOUT = -3 // The operation timed out.
};
int code = 0; // HTTP response code
std::string body; // Response body
std::map<std::string, std::string> headers; // Headers attached to the response
int code = 0;// HTTP response code
std::string body; // Response body
std::map<std::string, std::string> headers; // Headers attached to the response
};
/**
@ -156,9 +156,9 @@ class Async
public:
enum status_t
{
READY, // The result is ready.
ERROR, // The operation has failed.
PENDING // The operation is pending.
READY, // The result is ready.
ERROR, // The operation has failed.
PENDING // The operation is pending.
};
class Imp
@ -197,7 +197,7 @@ public:
*
* @return *this.
*/
Async& operator = (const Async& rhs)
Async& operator=(const Async& rhs)
{
std::shared_ptr<Imp> sImp(rhs.m_sImp);
m_sImp.swap(sImp);
@ -307,7 +307,5 @@ Async get_async(const std::vector<std::string>& urls,
Async get_async(const std::vector<std::string>& urls,
const std::string& user, const std::string& password,
const Config& config = Config());
}
}

View File

@ -51,17 +51,17 @@ public:
return prev;
}
bool operator == (const intrusive_slist_iterator& rhs) const
bool operator==(const intrusive_slist_iterator& rhs) const
{
return m_pT == rhs.m_pT;
}
bool operator != (const intrusive_slist_iterator& rhs) const
bool operator!=(const intrusive_slist_iterator& rhs) const
{
return !(m_pT == rhs.m_pT);
}
T& operator * () const
T& operator*() const
{
mxb_assert(m_pT);
return *m_pT;
@ -70,5 +70,4 @@ public:
private:
T* m_pT;
};
}

View File

@ -17,32 +17,32 @@
namespace maxbase
{
class PamResult
class PamResult
{
public:
enum class Result
{
public:
enum class Result
{
SUCCESS,
WRONG_USER_PW, /**< Username or password was wrong */
ACCOUNT_INVALID, /**< pam_acct_mgmt returned error */
MISC_ERROR /**< Miscellaneous error */
};
Result type {Result::MISC_ERROR};
std::string error;
SUCCESS,
WRONG_USER_PW, /**< Username or password was wrong */
ACCOUNT_INVALID, /**< pam_acct_mgmt returned error */
MISC_ERROR /**< Miscellaneous error */
};
/**
* Check if the user & password can log into the given PAM service. This function will block until the
* operation completes.
*
* @param user Username
* @param password Password
* @param service Which PAM service is the user logging to
* @param expected_msg The first expected message from the PAM authentication system.
* Typically "Password: ", which is also the default value. If set to empty, the message is not checked.
* @return A result struct with the result and an error message.
*/
PamResult pam_authenticate(const std::string& user, const std::string& password,
const std::string& service, const std::string& expected_msg = "Password: ");
Result type {Result::MISC_ERROR};
std::string error;
};
/**
* Check if the user & password can log into the given PAM service. This function will block until the
* operation completes.
*
* @param user Username
* @param password Password
* @param service Which PAM service is the user logging to
* @param expected_msg The first expected message from the PAM authentication system.
* Typically "Password: ", which is also the default value. If set to empty, the message is not checked.
* @return A result struct with the result and an error message.
*/
PamResult pam_authenticate(const std::string& user, const std::string& password,
const std::string& service, const std::string& expected_msg = "Password: ");
}

View File

@ -285,7 +285,7 @@ public:
* and in the latter `EINTR.
*/
bool timedwait(time_t seconds,
long nseconds,
long nseconds,
signal_approach_t signal_approach = IGNORE_SIGNALS) const
{
timespec ts;
@ -316,7 +316,7 @@ public:
*/
size_t timedwait_n(size_t n_wait,
time_t seconds,
long nseconds,
long nseconds,
signal_approach_t signal_approach = IGNORE_SIGNALS) const
{
timespec ts;

View File

@ -42,15 +42,15 @@ struct WORKER_STATISTICS
N_QUEUE_TIMES = 30
};
int64_t n_read = 0; /*< Number of read events */
int64_t n_write = 0; /*< Number of write events */
int64_t n_error = 0; /*< Number of error events */
int64_t n_hup = 0; /*< Number of hangup events */
int64_t n_accept = 0; /*< Number of accept events */
int64_t n_polls = 0; /*< Number of poll cycles */
int64_t n_pollev = 0; /*< Number of polls returning events */
int64_t evq_avg = 0; /*< Average event queue length */
int64_t evq_max = 0; /*< Maximum event queue length */
int64_t n_read = 0; /*< Number of read events */
int64_t n_write = 0; /*< Number of write events */
int64_t n_error = 0; /*< Number of error events */
int64_t n_hup = 0; /*< Number of hangup events */
int64_t n_accept = 0; /*< Number of accept events */
int64_t n_polls = 0; /*< Number of poll cycles */
int64_t n_pollev = 0; /*< Number of polls returning events */
int64_t evq_avg = 0; /*< Average event queue length */
int64_t evq_max = 0; /*< Maximum event queue length */
int64_t maxqtime = 0;
int64_t maxexectime = 0;
std::array<int64_t, MAXNFDS> n_fds {}; /*< Number of wakeups with particular n_fds value */
@ -249,12 +249,12 @@ class Worker : public MXB_WORKER
Worker& operator=(const Worker&) = delete;
public:
using STATISTICS = WORKER_STATISTICS;
using Task = WorkerTask;
using STATISTICS = WORKER_STATISTICS;
using Task = WorkerTask;
using DisposableTask = WorkerDisposableTask;
using Load = WorkerLoad;
using Timer = WorkerTimer;
using RandomEngine = maxbase::XorShiftRandom;
using Load = WorkerLoad;
using Timer = WorkerTimer;
using RandomEngine = maxbase::XorShiftRandom;
/**
* A delegating timer that delegates the timer tick handling