Uncrustify maxscale
See script directory for method. The script to run in the top level MaxScale directory is called maxscale-uncrustify.sh, which uses another script, list-src, from the same directory (so you need to set your PATH). The uncrustify version was 0.66.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <stdlib.h>
|
||||
@ -25,31 +25,31 @@ MXS_BEGIN_DECLS
|
||||
// "caller" arg temporarily disabled so that existing code
|
||||
// using the previous version of mxs_alloc etc. will continue
|
||||
// to compile.
|
||||
void *mxs_malloc(size_t size/*, const char *caller*/);
|
||||
void *mxs_calloc(size_t nmemb, size_t size/*, const char *caller*/);
|
||||
void *mxs_realloc(void *ptr, size_t size/*, const char *caller*/);
|
||||
void mxs_free(void *ptr/*, const char *caller*/);
|
||||
void* mxs_malloc(size_t size /*, const char *caller*/);
|
||||
void* mxs_calloc(size_t nmemb, size_t size /*, const char *caller*/);
|
||||
void* mxs_realloc(void* ptr, size_t size /*, const char *caller*/);
|
||||
void mxs_free(void* ptr /*, const char *caller*/);
|
||||
|
||||
char *mxs_strdup(const char *s/*, const char *caller*/);
|
||||
char *mxs_strndup(const char *s, size_t n/*, const char *caller*/);
|
||||
char* mxs_strdup(const char* s /*, const char *caller*/);
|
||||
char* mxs_strndup(const char* s, size_t n /*, const char *caller*/);
|
||||
|
||||
char *mxs_strdup_a(const char *s/*, const char *caller*/);
|
||||
char *mxs_strndup_a(const char *s, size_t n/*, const char *caller*/);
|
||||
char* mxs_strdup_a(const char* s /*, const char *caller*/);
|
||||
char* mxs_strndup_a(const char* s, size_t n /*, const char *caller*/);
|
||||
|
||||
|
||||
/*
|
||||
* NOTE: USE these macros instead of the functions above.
|
||||
*/
|
||||
#define MXS_MALLOC(size) mxs_malloc(size/*, __func__*/)
|
||||
#define MXS_CALLOC(nmemb, size) mxs_calloc(nmemb, size/*, __func__*/)
|
||||
#define MXS_REALLOC(ptr, size) mxs_realloc(ptr, size/*, __func__*/)
|
||||
#define MXS_FREE(ptr) mxs_free(ptr/*, __func__*/)
|
||||
#define MXS_MALLOC(size) mxs_malloc(size /*, __func__*/)
|
||||
#define MXS_CALLOC(nmemb, size) mxs_calloc(nmemb, size /*, __func__*/)
|
||||
#define MXS_REALLOC(ptr, size) mxs_realloc(ptr, size /*, __func__*/)
|
||||
#define MXS_FREE(ptr) mxs_free(ptr /*, __func__*/)
|
||||
|
||||
#define MXS_STRDUP(s) mxs_strdup(s/*, __func__*/)
|
||||
#define MXS_STRNDUP(s, n) mxs_strndup(s, n/*, __func__*/)
|
||||
#define MXS_STRDUP(s) mxs_strdup(s /*, __func__*/)
|
||||
#define MXS_STRNDUP(s, n) mxs_strndup(s, n /*, __func__*/)
|
||||
|
||||
#define MXS_STRDUP_A(s) mxs_strdup_a(s/*, __func__*/)
|
||||
#define MXS_STRNDUP_A(s, n) mxs_strndup_a(s, n/*, __func__*/)
|
||||
#define MXS_STRDUP_A(s) mxs_strdup_a(s /*, __func__*/)
|
||||
#define MXS_STRNDUP_A(s, n) mxs_strndup_a(s, n /*, __func__*/)
|
||||
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ char *mxs_strndup_a(const char *s, size_t n/*, const char *caller*/);
|
||||
* To be used in circumstances where a memory allocation failure
|
||||
* cannot - currently - be dealt with properly.
|
||||
*/
|
||||
#define MXS_ABORT_IF_NULL(p) do { if (!p) { abort(); } } while (false)
|
||||
#define MXS_ABORT_IF_NULL(p) do {if (!p) {abort();}} while (false)
|
||||
|
||||
/**
|
||||
* @brief Abort the process if the provided value is non-zero.
|
||||
@ -66,7 +66,7 @@ char *mxs_strndup_a(const char *s, size_t n/*, const char *caller*/);
|
||||
* To be used in circumstances where a memory allocation or other
|
||||
* fatal error cannot - currently - be dealt with properly.
|
||||
*/
|
||||
#define MXS_ABORT_IF_TRUE(b) do { if (b) { abort(); } } while (false)
|
||||
#define MXS_ABORT_IF_TRUE(b) do {if (b) {abort();}} while (false)
|
||||
|
||||
/**
|
||||
* @brief Abort the process if the provided value is zero.
|
||||
@ -74,6 +74,6 @@ char *mxs_strndup_a(const char *s, size_t n/*, const char *caller*/);
|
||||
* To be used in circumstances where a memory allocation or other
|
||||
* fatal error cannot - currently - be dealt with properly.
|
||||
*/
|
||||
#define MXS_ABORT_IF_FALSE(b) do { if (!b) { abort(); } } while (false)
|
||||
#define MXS_ABORT_IF_FALSE(b) do {if (!b) {abort();}} while (false)
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file authenticator.h
|
||||
@ -35,7 +35,7 @@ MXS_BEGIN_DECLS
|
||||
*/
|
||||
typedef enum authenticator_capability
|
||||
{
|
||||
ACAP_TYPE_ASYNC = 0x000100000000/**< Supports asynchronous access */
|
||||
ACAP_TYPE_ASYNC = 0x000100000000 /**< Supports asynchronous access */
|
||||
} authenticator_capability_t;
|
||||
|
||||
/** Maximum number of authenticator options */
|
||||
@ -89,15 +89,15 @@ struct servlistener;
|
||||
*/
|
||||
typedef struct mxs_authenticator
|
||||
{
|
||||
void* (*initialize)(char **options);
|
||||
void* (*initialize)(char** options);
|
||||
void* (*create)(void* instance);
|
||||
bool (*extract)(struct dcb *, GWBUF *);
|
||||
bool (*connectssl)(struct dcb *);
|
||||
int (*authenticate)(struct dcb *);
|
||||
void (*free)(struct dcb *);
|
||||
void (*destroy)(void *);
|
||||
int (*loadusers)(struct servlistener *);
|
||||
void (*diagnostic)(struct dcb*, struct servlistener *);
|
||||
bool (* extract)(struct dcb*, GWBUF*);
|
||||
bool (* connectssl)(struct dcb*);
|
||||
int (* authenticate)(struct dcb*);
|
||||
void (* free)(struct dcb*);
|
||||
void (* destroy)(void*);
|
||||
int (* loadusers)(struct servlistener*);
|
||||
void (* diagnostic)(struct dcb*, struct servlistener*);
|
||||
|
||||
/**
|
||||
* @brief Return diagnostic information about the authenticator
|
||||
@ -111,32 +111,38 @@ typedef struct mxs_authenticator
|
||||
*
|
||||
* @see jansson.h
|
||||
*/
|
||||
json_t* (*diagnostic_json)(const struct servlistener *listener);
|
||||
json_t* (*diagnostic_json)(const struct servlistener* listener);
|
||||
|
||||
/** This entry point was added to avoid calling authenticator functions
|
||||
* directly when a COM_CHANGE_USER command is executed. */
|
||||
int (*reauthenticate)(struct dcb *, const char *user,
|
||||
uint8_t *token, size_t token_len, /**< Client auth token */
|
||||
uint8_t *scramble, size_t scramble_len, /**< Scramble sent by MaxScale to client */
|
||||
uint8_t *output, size_t output_len); /**< Hashed client password used by backend protocols */
|
||||
int (* reauthenticate)(struct dcb*,
|
||||
const char* user,
|
||||
uint8_t* token,
|
||||
size_t token_len, /**< Client auth token */
|
||||
uint8_t* scramble,
|
||||
size_t scramble_len, /**< Scramble sent by MaxScale to client
|
||||
* */
|
||||
uint8_t* output,
|
||||
size_t output_len); /**< Hashed client password used by backend
|
||||
* protocols */
|
||||
} MXS_AUTHENTICATOR;
|
||||
|
||||
/** Return values for extract and authenticate entry points */
|
||||
#define MXS_AUTH_SUCCEEDED 0 /**< Authentication was successful */
|
||||
#define MXS_AUTH_FAILED 1 /**< Authentication failed */
|
||||
#define MXS_AUTH_FAILED_DB 2 /**< Authentication failed, database not found */
|
||||
#define MXS_AUTH_FAILED_SSL 3 /**< SSL authentication failed */
|
||||
#define MXS_AUTH_INCOMPLETE 4 /**< Authentication is not yet complete */
|
||||
#define MXS_AUTH_SSL_INCOMPLETE 5 /**< SSL connection is not yet complete */
|
||||
#define MXS_AUTH_SSL_COMPLETE 6 /**< SSL connection complete or not required */
|
||||
#define MXS_AUTH_NO_SESSION 7
|
||||
#define MXS_AUTH_BAD_HANDSHAKE 8 /**< Malformed client packet */
|
||||
#define MXS_AUTH_FAILED_WRONG_PASSWORD 9 /**< Client provided wrong password */
|
||||
#define MXS_AUTH_SUCCEEDED 0/**< Authentication was successful */
|
||||
#define MXS_AUTH_FAILED 1/**< Authentication failed */
|
||||
#define MXS_AUTH_FAILED_DB 2/**< Authentication failed, database not found */
|
||||
#define MXS_AUTH_FAILED_SSL 3/**< SSL authentication failed */
|
||||
#define MXS_AUTH_INCOMPLETE 4/**< Authentication is not yet complete */
|
||||
#define MXS_AUTH_SSL_INCOMPLETE 5/**< SSL connection is not yet complete */
|
||||
#define MXS_AUTH_SSL_COMPLETE 6/**< SSL connection complete or not required */
|
||||
#define MXS_AUTH_NO_SESSION 7
|
||||
#define MXS_AUTH_BAD_HANDSHAKE 8/**< Malformed client packet */
|
||||
#define MXS_AUTH_FAILED_WRONG_PASSWORD 9/**< Client provided wrong password */
|
||||
|
||||
/** Return values for the loadusers entry point */
|
||||
#define MXS_AUTH_LOADUSERS_OK 0 /**< Users loaded successfully */
|
||||
#define MXS_AUTH_LOADUSERS_ERROR 1 /**< Temporary error, service is started */
|
||||
#define MXS_AUTH_LOADUSERS_FATAL 2 /**< Fatal error, service is not started */
|
||||
#define MXS_AUTH_LOADUSERS_OK 0 /**< Users loaded successfully */
|
||||
#define MXS_AUTH_LOADUSERS_ERROR 1 /**< Temporary error, service is started */
|
||||
#define MXS_AUTH_LOADUSERS_FATAL 2 /**< Fatal error, service is not started */
|
||||
|
||||
/**
|
||||
* Authentication states
|
||||
@ -151,35 +157,64 @@ typedef struct mxs_authenticator
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MXS_AUTH_STATE_INIT, /**< Initial authentication state */
|
||||
MXS_AUTH_STATE_PENDING_CONNECT,/**< Connection creation is underway */
|
||||
MXS_AUTH_STATE_CONNECTED, /**< Network connection to server created */
|
||||
MXS_AUTH_STATE_MESSAGE_READ, /**< Read a authentication message from the server */
|
||||
MXS_AUTH_STATE_RESPONSE_SENT, /**< Responded to the read authentication message */
|
||||
MXS_AUTH_STATE_FAILED, /**< Authentication failed */
|
||||
MXS_AUTH_STATE_HANDSHAKE_FAILED, /**< Authentication failed immediately */
|
||||
MXS_AUTH_STATE_COMPLETE /**< Authentication is complete */
|
||||
MXS_AUTH_STATE_INIT, /**< Initial authentication state */
|
||||
MXS_AUTH_STATE_PENDING_CONNECT, /**< Connection creation is underway */
|
||||
MXS_AUTH_STATE_CONNECTED, /**< Network connection to server created */
|
||||
MXS_AUTH_STATE_MESSAGE_READ, /**< Read a authentication message from the server */
|
||||
MXS_AUTH_STATE_RESPONSE_SENT, /**< Responded to the read authentication message */
|
||||
MXS_AUTH_STATE_FAILED, /**< Authentication failed */
|
||||
MXS_AUTH_STATE_HANDSHAKE_FAILED,/**< Authentication failed immediately */
|
||||
MXS_AUTH_STATE_COMPLETE /**< Authentication is complete */
|
||||
} mxs_auth_state_t;
|
||||
|
||||
#define STRPROTOCOLSTATE(s) ((s) == MXS_AUTH_STATE_INIT ? "MXS_AUTH_STATE_INIT" : \
|
||||
((s) == MXS_AUTH_STATE_PENDING_CONNECT ? "MXS_AUTH_STATE_PENDING_CONNECT" : \
|
||||
((s) == MXS_AUTH_STATE_CONNECTED ? "MXS_AUTH_STATE_CONNECTED" : \
|
||||
((s) == MXS_AUTH_STATE_MESSAGE_READ ? "MXS_AUTH_STATE_MESSAGE_READ" : \
|
||||
((s) == MXS_AUTH_STATE_RESPONSE_SENT ? "MXS_AUTH_STATE_RESPONSE_SENT" : \
|
||||
((s) == MXS_AUTH_STATE_FAILED ? "MXS_AUTH_STATE_FAILED" : \
|
||||
((s) == MXS_AUTH_STATE_HANDSHAKE_FAILED ? "MXS_AUTH_STATE_HANDSHAKE_FAILED" : \
|
||||
((s) == MXS_AUTH_STATE_COMPLETE ? "MXS_AUTH_STATE_COMPLETE" : \
|
||||
"UNKNOWN AUTH STATE"))))))))
|
||||
#define STRPROTOCOLSTATE(s) \
|
||||
((s) == MXS_AUTH_STATE_INIT ? "MXS_AUTH_STATE_INIT" \
|
||||
: ((s) == MXS_AUTH_STATE_PENDING_CONNECT ? "MXS_AUTH_STATE_PENDING_CONNECT" \
|
||||
: ((s) \
|
||||
== MXS_AUTH_STATE_CONNECTED ? \
|
||||
"MXS_AUTH_STATE_CONNECTED" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
MXS_AUTH_STATE_MESSAGE_READ \
|
||||
? \
|
||||
"MXS_AUTH_STATE_MESSAGE_READ" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
MXS_AUTH_STATE_RESPONSE_SENT \
|
||||
? \
|
||||
"MXS_AUTH_STATE_RESPONSE_SENT" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
MXS_AUTH_STATE_FAILED \
|
||||
? \
|
||||
"MXS_AUTH_STATE_FAILED" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
MXS_AUTH_STATE_HANDSHAKE_FAILED \
|
||||
? \
|
||||
"MXS_AUTH_STATE_HANDSHAKE_FAILED" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
MXS_AUTH_STATE_COMPLETE \
|
||||
? \
|
||||
"MXS_AUTH_STATE_COMPLETE" \
|
||||
: \
|
||||
"UNKNOWN AUTH STATE"))))))))
|
||||
|
||||
/**
|
||||
* The MXS_AUTHENTICATOR version data. The following should be updated whenever
|
||||
* the MXS_AUTHENTICATOR structure is changed. See the rules defined in modinfo.h
|
||||
* that define how these numbers should change.
|
||||
*/
|
||||
#define MXS_AUTHENTICATOR_VERSION {2, 1, 0}
|
||||
#define MXS_AUTHENTICATOR_VERSION {2, 1, 0}
|
||||
|
||||
|
||||
bool authenticator_init(void **instance, const char *authenticator, const char *options);
|
||||
const char* get_default_authenticator(const char *protocol);
|
||||
bool authenticator_init(void** instance, const char* authenticator, const char* options);
|
||||
const char* get_default_authenticator(const char* protocol);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -29,7 +29,7 @@ namespace maxscale
|
||||
class Backend
|
||||
{
|
||||
Backend(const Backend&);
|
||||
Backend& operator =(const Backend&);
|
||||
Backend& operator=(const Backend&);
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -329,9 +329,9 @@ private:
|
||||
*/
|
||||
enum backend_state
|
||||
{
|
||||
IN_USE = 0x01, /**< Backend has been taken into use */
|
||||
WAITING_RESULT = 0x02, /**< Waiting for a reply */
|
||||
FATAL_FAILURE = 0x04 /**< Backend references that should be dropped */
|
||||
IN_USE = 0x01, /**< Backend has been taken into use */
|
||||
WAITING_RESULT = 0x02, /**< Waiting for a reply */
|
||||
FATAL_FAILURE = 0x04 /**< Backend references that should be dropped */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -349,16 +349,16 @@ private:
|
||||
void set_state(backend_state state);
|
||||
|
||||
|
||||
bool m_closed; /**< True if a connection has been opened and closed */
|
||||
SERVER_REF* m_backend; /**< Backend server */
|
||||
DCB* m_dcb; /**< Backend DCB */
|
||||
mxs::Buffer m_pending_cmd; /**< Pending commands */
|
||||
int m_state; /**< State of the backend */
|
||||
SessionCommandList m_session_commands; /**< List of session commands that are
|
||||
* to be executed on this backend server */
|
||||
std::string m_uri; /**< The combined address and port */
|
||||
bool m_closed; /**< True if a connection has been opened and closed */
|
||||
SERVER_REF* m_backend; /**< Backend server */
|
||||
DCB* m_dcb; /**< Backend DCB */
|
||||
mxs::Buffer m_pending_cmd; /**< Pending commands */
|
||||
int m_state; /**< State of the backend */
|
||||
SessionCommandList m_session_commands; /**< List of session commands that are
|
||||
* to be executed on this backend server */
|
||||
std::string m_uri; /**< The combined address and port */
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Backend> SBackend;
|
||||
typedef std::list<SBackend> BackendList;
|
||||
typedef std::list<SBackend> BackendList;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file buffer.h Definitions relating the gateway buffer manipulation facilities.
|
||||
@ -43,34 +43,34 @@ struct server;
|
||||
*/
|
||||
typedef struct buf_property
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
struct buf_property *next;
|
||||
char* name;
|
||||
char* value;
|
||||
struct buf_property* next;
|
||||
} BUF_PROPERTY;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GWBUF_TYPE_UNDEFINED = 0,
|
||||
GWBUF_TYPE_HTTP = (1 << 0),
|
||||
GWBUF_TYPE_IGNORABLE = (1 << 1),
|
||||
GWBUF_TYPE_COLLECT_RESULT = (1 << 2),
|
||||
GWBUF_TYPE_RESULT = (1 << 3),
|
||||
GWBUF_TYPE_REPLY_OK = (1 << 4),
|
||||
GWBUF_TYPE_UNDEFINED = 0,
|
||||
GWBUF_TYPE_HTTP = (1 << 0),
|
||||
GWBUF_TYPE_IGNORABLE = (1 << 1),
|
||||
GWBUF_TYPE_COLLECT_RESULT = (1 << 2),
|
||||
GWBUF_TYPE_RESULT = (1 << 3),
|
||||
GWBUF_TYPE_REPLY_OK = (1 << 4),
|
||||
} gwbuf_type_t;
|
||||
|
||||
#define GWBUF_IS_TYPE_UNDEFINED(b) ((b)->gwbuf_type == 0)
|
||||
#define GWBUF_IS_IGNORABLE(b) ((b)->gwbuf_type & GWBUF_TYPE_IGNORABLE)
|
||||
#define GWBUF_IS_COLLECTED_RESULT(b) ((b)->gwbuf_type & GWBUF_TYPE_RESULT)
|
||||
#define GWBUF_SHOULD_COLLECT_RESULT(b) ((b)->gwbuf_type & GWBUF_TYPE_COLLECT_RESULT)
|
||||
#define GWBUF_IS_REPLY_OK(b) ((b)->gwbuf_type & GWBUF_TYPE_REPLY_OK)
|
||||
#define GWBUF_IS_TYPE_UNDEFINED(b) ((b)->gwbuf_type == 0)
|
||||
#define GWBUF_IS_IGNORABLE(b) ((b)->gwbuf_type & GWBUF_TYPE_IGNORABLE)
|
||||
#define GWBUF_IS_COLLECTED_RESULT(b) ((b)->gwbuf_type & GWBUF_TYPE_RESULT)
|
||||
#define GWBUF_SHOULD_COLLECT_RESULT(b) ((b)->gwbuf_type & GWBUF_TYPE_COLLECT_RESULT)
|
||||
#define GWBUF_IS_REPLY_OK(b) ((b)->gwbuf_type & GWBUF_TYPE_REPLY_OK)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GWBUF_INFO_NONE = 0x0,
|
||||
GWBUF_INFO_PARSED = 0x1
|
||||
GWBUF_INFO_NONE = 0x0,
|
||||
GWBUF_INFO_PARSED = 0x1
|
||||
} gwbuf_info_t;
|
||||
|
||||
#define GWBUF_IS_PARSED(b) (b->sbuf->info & GWBUF_INFO_PARSED)
|
||||
#define GWBUF_IS_PARSED(b) (b->sbuf->info & GWBUF_INFO_PARSED)
|
||||
|
||||
/**
|
||||
* A structure for cleaning up memory allocations of structures which are
|
||||
@ -89,7 +89,7 @@ struct buffer_object_st
|
||||
{
|
||||
bufobj_id_t bo_id;
|
||||
void* bo_data;
|
||||
void (*bo_donefun_fp)(void *);
|
||||
void (* bo_donefun_fp)(void*);
|
||||
buffer_object_t* bo_next;
|
||||
};
|
||||
|
||||
@ -100,10 +100,10 @@ struct buffer_object_st
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
buffer_object_t *bufobj; /*< List of objects referred to by GWBUF */
|
||||
int32_t refcount; /*< Reference count on the buffer */
|
||||
uint32_t info; /*< Info bits */
|
||||
unsigned char data[1]; /*< Actual memory that was allocated */
|
||||
buffer_object_t* bufobj; /*< List of objects referred to by GWBUF */
|
||||
int32_t refcount; /*< Reference count on the buffer */
|
||||
uint32_t info; /*< Info bits */
|
||||
unsigned char data[1]; /*< Actual memory that was allocated */
|
||||
} SHARED_BUF;
|
||||
|
||||
/**
|
||||
@ -116,51 +116,55 @@ typedef struct
|
||||
*/
|
||||
typedef struct gwbuf
|
||||
{
|
||||
struct gwbuf *next; /*< Next buffer in a linked chain of buffers */
|
||||
struct gwbuf *tail; /*< Last buffer in a linked chain of buffers */
|
||||
void *start; /*< Start of the valid data */
|
||||
void *end; /*< First byte after the valid data */
|
||||
SHARED_BUF *sbuf; /*< The shared buffer with the real data */
|
||||
HINT *hint; /*< Hint data for this buffer */
|
||||
BUF_PROPERTY *properties; /*< Buffer properties */
|
||||
struct server *server; /*< The target server where the buffer is executed */
|
||||
uint32_t gwbuf_type; /*< buffer's data type information */
|
||||
struct gwbuf* next; /*< Next buffer in a linked chain of buffers */
|
||||
struct gwbuf* tail; /*< Last buffer in a linked chain of buffers */
|
||||
void* start; /*< Start of the valid data */
|
||||
void* end; /*< First byte after the valid data */
|
||||
SHARED_BUF* sbuf; /*< The shared buffer with the real data */
|
||||
HINT* hint; /*< Hint data for this buffer */
|
||||
BUF_PROPERTY* properties; /*< Buffer properties */
|
||||
struct server* server; /*< The target server where the buffer is executed */
|
||||
uint32_t gwbuf_type; /*< buffer's data type information */
|
||||
} GWBUF;
|
||||
|
||||
/*<
|
||||
* Macros to access the data in the buffers
|
||||
*/
|
||||
/*< First valid, unconsumed byte in the buffer */
|
||||
#define GWBUF_DATA(b) ((uint8_t*)(b)->start)
|
||||
#define GWBUF_DATA(b) ((uint8_t*)(b)->start)
|
||||
|
||||
/*< Number of bytes in the individual buffer */
|
||||
#define GWBUF_LENGTH(b) ((size_t)((char *)(b)->end - (char *)(b)->start))
|
||||
#define GWBUF_LENGTH(b) ((size_t)((char*)(b)->end - (char*)(b)->start))
|
||||
|
||||
/*< Return the byte at offset byte from the start of the unconsumed portion of the buffer */
|
||||
#define GWBUF_DATA_CHAR(b, byte) (GWBUF_LENGTH(b) < ((byte)+1) ? -1 : *(((char *)(b)->start)+4))
|
||||
#define GWBUF_DATA_CHAR(b, byte) (GWBUF_LENGTH(b) < ((byte) + 1) ? -1 : *(((char*)(b)->start) + 4))
|
||||
|
||||
/*< Check that the data in a buffer has the SQL marker*/
|
||||
#define GWBUF_IS_SQL(b) (0x03 == GWBUF_DATA_CHAR(b,4))
|
||||
#define GWBUF_IS_SQL(b) (0x03 == GWBUF_DATA_CHAR(b, 4))
|
||||
|
||||
/*< Check whether the buffer is contiguous*/
|
||||
#define GWBUF_IS_CONTIGUOUS(b) (((b) == NULL) || ((b)->next == NULL))
|
||||
|
||||
/*< True if all bytes in the buffer have been consumed */
|
||||
#define GWBUF_EMPTY(b) ((char *)(b)->start >= (char *)(b)->end)
|
||||
#define GWBUF_EMPTY(b) ((char*)(b)->start >= (char*)(b)->end)
|
||||
|
||||
/*< Consume a number of bytes in the buffer */
|
||||
#define GWBUF_CONSUME(b, bytes) ((b)->start = bytes > ((char *)(b)->end - (char *)(b)->start) ? (b)->end : (void *)((char *)(b)->start + (bytes)));
|
||||
#define GWBUF_CONSUME(b, \
|
||||
bytes) ((b)->start = bytes \
|
||||
> ((char*)(b)->end \
|
||||
- (char*)(b)->start) ? (b)->end : (void*)((char*)(b)->start + (bytes)));
|
||||
|
||||
/*< Check if a given pointer is within the buffer */
|
||||
#define GWBUF_POINTER_IN_BUFFER (ptr, b)\
|
||||
((char *)(ptr) >= (char *)(b)->start && (char *)(ptr) < (char *)(b)->end)
|
||||
#define GWBUF_POINTER_IN_BUFFER \
|
||||
(ptr, b) \
|
||||
((char*)(ptr) >= (char*)(b)->start && (char*)(ptr) < (char*)(b)->end)
|
||||
|
||||
/*< Consume a complete buffer */
|
||||
#define GWBUF_CONSUME_ALL(b) gwbuf_consume((b), GWBUF_LENGTH((b)))
|
||||
#define GWBUF_CONSUME_ALL(b) gwbuf_consume((b), GWBUF_LENGTH((b)))
|
||||
|
||||
#define GWBUF_RTRIM(b, bytes)\
|
||||
((b)->end = bytes > ((char *)(b)->end - (char *)(b)->start) ? (b)->start : \
|
||||
(void *)((char *)(b)->end - (bytes)));
|
||||
#define GWBUF_RTRIM(b, bytes) \
|
||||
((b)->end = bytes > ((char*)(b)->end - (char*)(b)->start) ? (b)->start \
|
||||
: (void*)((char*)(b)->end - (bytes)));
|
||||
|
||||
#define GWBUF_TYPE(b) (b)->gwbuf_type
|
||||
/*<
|
||||
@ -175,7 +179,7 @@ typedef struct gwbuf
|
||||
* @return Pointer to the buffer structure or NULL if memory could not
|
||||
* be allocated.
|
||||
*/
|
||||
extern GWBUF *gwbuf_alloc(unsigned int size);
|
||||
extern GWBUF* gwbuf_alloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* Allocate a new gateway buffer structure of specified size and load with data.
|
||||
@ -186,14 +190,14 @@ extern GWBUF *gwbuf_alloc(unsigned int size);
|
||||
* @return Pointer to the buffer structure or NULL if memory could not
|
||||
* be allocated.
|
||||
*/
|
||||
extern GWBUF *gwbuf_alloc_and_load(unsigned int size, const void *data);
|
||||
extern GWBUF* gwbuf_alloc_and_load(unsigned int size, const void* data);
|
||||
|
||||
/**
|
||||
* Free a chain of gateway buffers
|
||||
*
|
||||
* @param buf The head of the list of buffers to free
|
||||
*/
|
||||
extern void gwbuf_free(GWBUF *buf);
|
||||
extern void gwbuf_free(GWBUF* buf);
|
||||
|
||||
/**
|
||||
* Clone a GWBUF. Note that if the GWBUF is actually a list of
|
||||
@ -205,7 +209,7 @@ extern void gwbuf_free(GWBUF *buf);
|
||||
* @return The cloned GWBUF, or NULL if @buf was NULL or if any part
|
||||
* of @buf could not be cloned.
|
||||
*/
|
||||
extern GWBUF *gwbuf_clone(GWBUF *buf);
|
||||
extern GWBUF* gwbuf_clone(GWBUF* buf);
|
||||
|
||||
/**
|
||||
* @brief Deep clone a GWBUF
|
||||
@ -253,7 +257,7 @@ extern int gwbuf_compare(const GWBUF* lhs, const GWBUF* rhs);
|
||||
*
|
||||
* @return The new head of the linked list
|
||||
*/
|
||||
extern GWBUF *gwbuf_append(GWBUF *head, GWBUF *tail);
|
||||
extern GWBUF* gwbuf_append(GWBUF* head, GWBUF* tail);
|
||||
|
||||
/**
|
||||
* @brief Consume data from buffer chain
|
||||
@ -268,7 +272,7 @@ extern GWBUF *gwbuf_append(GWBUF *head, GWBUF *tail);
|
||||
*
|
||||
* @return The head of the linked list or NULL if everything was consumed
|
||||
*/
|
||||
extern GWBUF *gwbuf_consume(GWBUF *head, unsigned int length);
|
||||
extern GWBUF* gwbuf_consume(GWBUF* head, unsigned int length);
|
||||
|
||||
/**
|
||||
* Trim bytes from the end of a GWBUF structure that may be the first
|
||||
@ -280,7 +284,7 @@ extern GWBUF *gwbuf_consume(GWBUF *head, unsigned int length);
|
||||
*
|
||||
* @return The buffer chain or NULL if buffer chain now empty
|
||||
*/
|
||||
extern GWBUF *gwbuf_rtrim(GWBUF *head, unsigned int length);
|
||||
extern GWBUF* gwbuf_rtrim(GWBUF* head, unsigned int length);
|
||||
|
||||
/**
|
||||
* Return the number of bytes of data in the linked list.
|
||||
@ -289,7 +293,7 @@ extern GWBUF *gwbuf_rtrim(GWBUF *head, unsigned int length);
|
||||
*
|
||||
* @return The number of bytes of data in the linked list
|
||||
*/
|
||||
extern unsigned int gwbuf_length(const GWBUF *head);
|
||||
extern unsigned int gwbuf_length(const GWBUF* head);
|
||||
|
||||
/**
|
||||
* Return the number of individual buffers in the linked list.
|
||||
@ -300,7 +304,7 @@ extern unsigned int gwbuf_length(const GWBUF *head);
|
||||
*
|
||||
* @return The number of bytes of data in the linked list
|
||||
*/
|
||||
extern int gwbuf_count(const GWBUF *head);
|
||||
extern int gwbuf_count(const GWBUF* head);
|
||||
|
||||
/**
|
||||
* @brief Copy bytes from a buffer
|
||||
@ -315,7 +319,7 @@ extern int gwbuf_count(const GWBUF *head);
|
||||
*
|
||||
* @return Number of bytes copied.
|
||||
*/
|
||||
extern size_t gwbuf_copy_data(const GWBUF *buffer, size_t offset, size_t bytes, uint8_t* dest);
|
||||
extern size_t gwbuf_copy_data(const GWBUF* buffer, size_t offset, size_t bytes, uint8_t* dest);
|
||||
|
||||
/**
|
||||
* @brief Split a buffer in two
|
||||
@ -328,7 +332,7 @@ extern size_t gwbuf_copy_data(const GWBUF *buffer, size_t offset, size_t bytes,
|
||||
*
|
||||
* @return Head of the buffer chain.
|
||||
*/
|
||||
extern GWBUF *gwbuf_split(GWBUF **buf, size_t length);
|
||||
extern GWBUF* gwbuf_split(GWBUF** buf, size_t length);
|
||||
|
||||
/**
|
||||
* Set given type to all buffers on the list.
|
||||
@ -336,7 +340,7 @@ extern GWBUF *gwbuf_split(GWBUF **buf, size_t length);
|
||||
* @param buf The shared buffer
|
||||
* @param type Type to be added, mask of @c gwbuf_type_t values.
|
||||
*/
|
||||
extern void gwbuf_set_type(GWBUF *head, uint32_t type);
|
||||
extern void gwbuf_set_type(GWBUF* head, uint32_t type);
|
||||
|
||||
/**
|
||||
* Add a property to a buffer.
|
||||
@ -347,7 +351,7 @@ extern void gwbuf_set_type(GWBUF *head, uint32_t type);
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
extern bool gwbuf_add_property(GWBUF *buf, const char *name, const char *value);
|
||||
extern bool gwbuf_add_property(GWBUF* buf, const char* name, const char* value);
|
||||
|
||||
/**
|
||||
* Return the value of a buffer property
|
||||
@ -357,7 +361,7 @@ extern bool gwbuf_add_property(GWBUF *buf, const char *name, const char *value);
|
||||
*
|
||||
* @return The property value or NULL if the property was not found.
|
||||
*/
|
||||
extern char *gwbuf_get_property(GWBUF *buf, const char *name);
|
||||
extern char* gwbuf_get_property(GWBUF* buf, const char* name);
|
||||
|
||||
/**
|
||||
* Convert a chain of GWBUF structures into a single GWBUF structure
|
||||
@ -368,7 +372,7 @@ extern char *gwbuf_get_property(GWBUF *buf, const char *name);
|
||||
*
|
||||
* @attention Never returns NULL, memory allocation failures abort the process
|
||||
*/
|
||||
extern GWBUF* gwbuf_make_contiguous(GWBUF *buf);
|
||||
extern GWBUF* gwbuf_make_contiguous(GWBUF* buf);
|
||||
|
||||
/**
|
||||
* Add a buffer object to GWBUF buffer.
|
||||
@ -380,8 +384,8 @@ extern GWBUF* gwbuf_make_contiguous(GWBUF *buf);
|
||||
*/
|
||||
void gwbuf_add_buffer_object(GWBUF* buf,
|
||||
bufobj_id_t id,
|
||||
void* data,
|
||||
void (*donefun_fp)(void *));
|
||||
void* data,
|
||||
void (* donefun_fp)(void*));
|
||||
|
||||
/**
|
||||
* Search buffer object which matches with the id.
|
||||
@ -391,9 +395,9 @@ void gwbuf_add_buffer_object(GWBUF* buf,
|
||||
*
|
||||
* @return Searched buffer object or NULL if not found
|
||||
*/
|
||||
void *gwbuf_get_buffer_object_data(GWBUF* buf, bufobj_id_t id);
|
||||
#if defined(BUFFER_TRACE)
|
||||
extern void dprintAllBuffers(void *pdcb);
|
||||
void* gwbuf_get_buffer_object_data(GWBUF* buf, bufobj_id_t id);
|
||||
#if defined (BUFFER_TRACE)
|
||||
extern void dprintAllBuffers(void* pdcb);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -414,6 +418,6 @@ void gwbuf_hexdump(GWBUF* buffer, int log_level);
|
||||
* @return if total buffer length is bigger than offset then return
|
||||
* the offset byte pointer, otherwise return null
|
||||
*/
|
||||
extern uint8_t *gwbuf_byte_pointer(GWBUF* buffer, size_t offset);
|
||||
extern uint8_t* gwbuf_byte_pointer(GWBUF* buffer, size_t offset);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <algorithm>
|
||||
@ -32,7 +32,6 @@ struct default_delete<GWBUF>
|
||||
gwbuf_free(pBuffer);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace maxscale
|
||||
@ -57,12 +56,12 @@ public:
|
||||
// pointer_type : The type of a pointer to an element, either "uint8_t*" or "const uint8_t*".
|
||||
// reference_type: The type of a reference to an element, either "uint8_t&" or "const uint8_t&".
|
||||
template<class buf_type, class pointer_type, class reference_type>
|
||||
class iterator_base : public std::iterator <
|
||||
std::forward_iterator_tag, // The type of the iterator
|
||||
uint8_t, // The type of the elems
|
||||
std::ptrdiff_t, // Difference between two its
|
||||
pointer_type, // The type of pointer to an elem
|
||||
reference_type > // The reference type of an elem
|
||||
class iterator_base : public std::iterator<
|
||||
std::forward_iterator_tag // The type of the iterator
|
||||
, uint8_t // The type of the elems
|
||||
, std::ptrdiff_t // Difference between two its
|
||||
, pointer_type // The type of pointer to an elem
|
||||
, reference_type> // The reference type of an elem
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -84,7 +83,8 @@ public:
|
||||
: m_pBuffer(pBuffer)
|
||||
, m_i(m_pBuffer ? GWBUF_DATA(m_pBuffer) : NULL)
|
||||
, m_end(m_pBuffer ? (m_i + GWBUF_LENGTH(m_pBuffer)) : NULL)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void advance()
|
||||
{
|
||||
@ -140,7 +140,8 @@ public:
|
||||
public:
|
||||
explicit iterator(GWBUF* pBuffer = NULL)
|
||||
: iterator_base_typedef(pBuffer)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
iterator& operator++()
|
||||
{
|
||||
@ -155,12 +156,12 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool operator == (const iterator& rhs) const
|
||||
bool operator==(const iterator& rhs) const
|
||||
{
|
||||
return eq(rhs);
|
||||
}
|
||||
|
||||
bool operator != (const iterator& rhs) const
|
||||
bool operator!=(const iterator& rhs) const
|
||||
{
|
||||
return neq(rhs);
|
||||
}
|
||||
@ -183,11 +184,13 @@ public:
|
||||
public:
|
||||
explicit const_iterator(const GWBUF* pBuffer = NULL)
|
||||
: const_iterator_base_typedef(pBuffer)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const Buffer::iterator& rhs)
|
||||
: const_iterator_base_typedef(rhs.m_pBuffer)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator& operator++()
|
||||
{
|
||||
@ -202,12 +205,12 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool operator == (const const_iterator& rhs) const
|
||||
bool operator==(const const_iterator& rhs) const
|
||||
{
|
||||
return eq(rhs);
|
||||
}
|
||||
|
||||
bool operator != (const const_iterator& rhs) const
|
||||
bool operator!=(const const_iterator& rhs) const
|
||||
{
|
||||
return neq(rhs);
|
||||
}
|
||||
@ -224,7 +227,8 @@ public:
|
||||
*/
|
||||
Buffer()
|
||||
: m_pBuffer(NULL)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
@ -275,7 +279,8 @@ public:
|
||||
*/
|
||||
Buffer(GWBUF* pBuffer)
|
||||
: m_pBuffer(pBuffer)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a buffer of specified size.
|
||||
@ -353,7 +358,7 @@ public:
|
||||
*
|
||||
* @see Buffer::copy_from
|
||||
*/
|
||||
Buffer& operator = (const Buffer& rhs)
|
||||
Buffer& operator=(const Buffer& rhs)
|
||||
{
|
||||
Buffer temp(rhs);
|
||||
swap(temp);
|
||||
@ -366,7 +371,7 @@ public:
|
||||
*
|
||||
* @param rhs The @c Buffer to be moves.
|
||||
*/
|
||||
Buffer& operator = (Buffer&& rhs)
|
||||
Buffer& operator=(Buffer&& rhs)
|
||||
{
|
||||
reset();
|
||||
swap(rhs);
|
||||
@ -626,7 +631,7 @@ public:
|
||||
*
|
||||
* @attention Invalidates all iterators.
|
||||
*/
|
||||
GWBUF** operator & ()
|
||||
GWBUF** operator&()
|
||||
{
|
||||
reset();
|
||||
return &m_pBuffer;
|
||||
@ -689,10 +694,10 @@ public:
|
||||
|
||||
private:
|
||||
// To prevent @c Buffer from being created on the heap.
|
||||
void* operator new(size_t); // standard new
|
||||
void* operator new(size_t, void*); // placement new
|
||||
void* operator new[](size_t); // array new
|
||||
void* operator new[](size_t, void*); // placement array new
|
||||
void* operator new(size_t); // standard new
|
||||
void* operator new(size_t, void*); // placement new
|
||||
void* operator new[](size_t); // array new
|
||||
void* operator new[](size_t, void*);// placement array new
|
||||
|
||||
private:
|
||||
GWBUF* m_pBuffer;
|
||||
@ -703,7 +708,7 @@ private:
|
||||
*
|
||||
* @return True if equal, false otherwise.
|
||||
*/
|
||||
inline bool operator == (const Buffer& lhs, const Buffer& rhs)
|
||||
inline bool operator==(const Buffer& lhs, const Buffer& rhs)
|
||||
{
|
||||
return lhs.eq(rhs);
|
||||
}
|
||||
@ -713,7 +718,7 @@ inline bool operator == (const Buffer& lhs, const Buffer& rhs)
|
||||
*
|
||||
* @return True if equal, false otherwise.
|
||||
*/
|
||||
inline bool operator == (const Buffer& lhs, const GWBUF& rhs)
|
||||
inline bool operator==(const Buffer& lhs, const GWBUF& rhs)
|
||||
{
|
||||
return lhs.eq(rhs);
|
||||
}
|
||||
@ -723,7 +728,7 @@ inline bool operator == (const Buffer& lhs, const GWBUF& rhs)
|
||||
*
|
||||
* @return True if un-equal, false otherwise.
|
||||
*/
|
||||
inline bool operator != (const Buffer& lhs, const Buffer& rhs)
|
||||
inline bool operator!=(const Buffer& lhs, const Buffer& rhs)
|
||||
{
|
||||
return !lhs.eq(rhs);
|
||||
}
|
||||
@ -733,9 +738,8 @@ inline bool operator != (const Buffer& lhs, const Buffer& rhs)
|
||||
*
|
||||
* @return True if un-equal, false otherwise.
|
||||
*/
|
||||
inline bool operator != (const Buffer& lhs, const GWBUF& rhs)
|
||||
inline bool operator!=(const Buffer& lhs, const GWBUF& rhs)
|
||||
{
|
||||
return !lhs.eq(rhs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ccdefs.hh
|
||||
@ -18,7 +18,7 @@
|
||||
* This file is to be included first by all C++ headers.
|
||||
*/
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#if !defined (__cplusplus)
|
||||
#error This file is only to be included by C++ code.
|
||||
#endif
|
||||
|
||||
@ -57,8 +57,8 @@ namespace mxs = maxscale;
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#define MXS_EXCEPTION_GUARD(statement)\
|
||||
do { try { statement; }\
|
||||
catch (const std::bad_alloc&) { MXS_OOM(); }\
|
||||
catch (const std::exception& x) { MXS_ERROR("Caught standard exception: %s", x.what()); }\
|
||||
catch (...) { MXS_ERROR("Caught unknown exception."); } } while (false)
|
||||
#define MXS_EXCEPTION_GUARD(statement) \
|
||||
do {try {statement;} \
|
||||
catch (const std::bad_alloc&) {MXS_OOM();} \
|
||||
catch (const std::exception& x) {MXS_ERROR("Caught standard exception: %s", x.what());} \
|
||||
catch (...) {MXS_ERROR("Caught unknown exception.");}} while (false)
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file cdefs.h
|
||||
@ -48,7 +48,7 @@
|
||||
*
|
||||
* @note This a macro, so the arguments will be evaluated more than once.
|
||||
*/
|
||||
#define MXS_MIN(a,b) ((a)<(b) ? (a) : (b))
|
||||
#define MXS_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/**
|
||||
* Returns the larger of two items.
|
||||
@ -60,7 +60,7 @@
|
||||
*
|
||||
* @note This a macro, so the arguments will be evaluated more than once.
|
||||
*/
|
||||
#define MXS_MAX(a,b) ((a)>(b) ? (a) : (b))
|
||||
#define MXS_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/**
|
||||
* Define function attributes
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/config.h The configuration handling elements
|
||||
@ -44,11 +44,11 @@ MXS_BEGIN_DECLS
|
||||
#define DEFAULT_ADMIN_HTTP_PORT 8989
|
||||
#define DEFAULT_ADMIN_HOST "127.0.0.1"
|
||||
|
||||
#define RELEASE_STR_LENGTH 256
|
||||
#define SYSNAME_LEN 256
|
||||
#define MAX_ADMIN_USER_LEN 1024
|
||||
#define MAX_ADMIN_PW_LEN 1024
|
||||
#define MAX_ADMIN_HOST_LEN 1024
|
||||
#define RELEASE_STR_LENGTH 256
|
||||
#define SYSNAME_LEN 256
|
||||
#define MAX_ADMIN_USER_LEN 1024
|
||||
#define MAX_ADMIN_PW_LEN 1024
|
||||
#define MAX_ADMIN_HOST_LEN 1024
|
||||
|
||||
/** JSON Pointers to key parts of JSON objects */
|
||||
#define MXS_JSON_PTR_DATA "/data"
|
||||
@ -220,9 +220,9 @@ extern const char CN_LOG_TO_SHM[];
|
||||
*/
|
||||
typedef struct config_parameter
|
||||
{
|
||||
char *name; /**< The name of the parameter */
|
||||
char *value; /**< The value of the parameter */
|
||||
struct config_parameter *next; /**< Next pointer in the linked list */
|
||||
char* name; /**< The name of the parameter */
|
||||
char* value; /**< The value of the parameter */
|
||||
struct config_parameter* next; /**< Next pointer in the linked list */
|
||||
} MXS_CONFIG_PARAMETER;
|
||||
|
||||
/**
|
||||
@ -231,10 +231,10 @@ typedef struct config_parameter
|
||||
*/
|
||||
typedef struct config_context
|
||||
{
|
||||
char *object; /**< The name of the object being configured */
|
||||
MXS_CONFIG_PARAMETER *parameters; /**< The list of parameter values */
|
||||
bool was_persisted; /**< True if this object was persisted */
|
||||
struct config_context *next; /**< Next pointer in the linked list */
|
||||
char* object; /**< The name of the object being configured */
|
||||
MXS_CONFIG_PARAMETER* parameters; /**< The list of parameter values */
|
||||
bool was_persisted; /**< True if this object was persisted */
|
||||
struct config_context* next; /**< Next pointer in the linked list */
|
||||
} CONFIG_CONTEXT;
|
||||
|
||||
/**
|
||||
@ -242,47 +242,53 @@ typedef struct config_context
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool config_check; /**< Only check config */
|
||||
int n_threads; /**< Number of polling threads */
|
||||
size_t thread_stack_size; /**< The stack size of each worker thread */
|
||||
char *version_string; /**< The version string of embedded db library */
|
||||
char release_string[RELEASE_STR_LENGTH]; /**< The release name string of the system */
|
||||
char sysname[SYSNAME_LEN]; /**< The OS name of the system */
|
||||
uint8_t mac_sha1[SHA_DIGEST_LENGTH]; /**< The SHA1 digest of an interface MAC address */
|
||||
unsigned int n_nbpoll; /**< Tune number of non-blocking polls */
|
||||
unsigned int pollsleep; /**< Wait time in blocking polls */
|
||||
int syslog; /**< Log to syslog */
|
||||
int maxlog; /**< Log to MaxScale's own logs */
|
||||
unsigned int auth_conn_timeout; /**< Connection timeout for the user authentication */
|
||||
unsigned int auth_read_timeout; /**< Read timeout for the user authentication */
|
||||
unsigned int auth_write_timeout; /**< Write timeout for the user authentication */
|
||||
bool skip_permission_checks; /**< Skip service and monitor permission checks */
|
||||
int32_t passive; /**< True if MaxScale is in passive mode */
|
||||
int64_t promoted_at; /**< Time when this Maxscale instance was
|
||||
* promoted from a passive to an active */
|
||||
char qc_name[PATH_MAX]; /**< The name of the query classifier to load */
|
||||
char* qc_args; /**< Arguments for the query classifier */
|
||||
QC_CACHE_PROPERTIES qc_cache_properties; /**< The query classifier cache properties. */
|
||||
qc_sql_mode_t qc_sql_mode; /**< The query classifier sql mode */
|
||||
char admin_host[MAX_ADMIN_HOST_LEN]; /**< Admin interface host */
|
||||
uint16_t admin_port; /**< Admin interface port */
|
||||
bool admin_auth; /**< Admin interface authentication */
|
||||
bool admin_enabled; /**< Admin interface is enabled */
|
||||
bool admin_log_auth_failures; /**< Log admin interface authentication failures */
|
||||
char admin_ssl_key[PATH_MAX]; /**< Admin SSL key */
|
||||
char admin_ssl_cert[PATH_MAX]; /**< Admin SSL cert */
|
||||
char admin_ssl_ca_cert[PATH_MAX]; /**< Admin SSL CA cert */
|
||||
int query_retries; /**< Number of times a interrupted query is retried */
|
||||
time_t query_retry_timeout; /**< Timeout for query retries */
|
||||
bool substitute_variables; /**< Should environment variables be substituted */
|
||||
char* local_address; /**< Local address to use when connecting */
|
||||
time_t users_refresh_time; /**< How often the users can be refreshed */
|
||||
uint64_t writeq_high_water; /**< High water mark of dcb write queue */
|
||||
uint64_t writeq_low_water; /**< Low water mark of dcb write queue */
|
||||
char peer_hosts[MAX_ADMIN_HOST_LEN]; /**< The protocol, address and port for peers (currently only one) */
|
||||
char peer_user[MAX_ADMIN_HOST_LEN]; /**< Username for maxscale-to-maxscale traffic */
|
||||
char peer_password[MAX_ADMIN_HOST_LEN]; /**< Password for maxscale-to-maxscale traffic */
|
||||
mxb_log_target_t log_target; /**< Log type */
|
||||
bool config_check; /**< Only check config */
|
||||
int n_threads; /**< Number of polling threads */
|
||||
size_t thread_stack_size; /**< The stack size of each worker thread */
|
||||
char* version_string; /**< The version string of embedded db library */
|
||||
char release_string[RELEASE_STR_LENGTH]; /**< The release name string of the system */
|
||||
char sysname[SYSNAME_LEN]; /**< The OS name of the system */
|
||||
uint8_t mac_sha1[SHA_DIGEST_LENGTH]; /**< The SHA1 digest of an interface MAC address
|
||||
* */
|
||||
unsigned int n_nbpoll; /**< Tune number of non-blocking polls */
|
||||
unsigned int pollsleep; /**< Wait time in blocking polls */
|
||||
int syslog; /**< Log to syslog */
|
||||
int maxlog; /**< Log to MaxScale's own logs */
|
||||
unsigned int auth_conn_timeout; /**< Connection timeout for the user
|
||||
* authentication */
|
||||
unsigned int auth_read_timeout; /**< Read timeout for the user authentication */
|
||||
unsigned int auth_write_timeout; /**< Write timeout for the user authentication */
|
||||
bool skip_permission_checks; /**< Skip service and monitor permission checks */
|
||||
int32_t passive; /**< True if MaxScale is in passive mode */
|
||||
int64_t promoted_at; /**< Time when this Maxscale instance was
|
||||
* promoted from a passive to an active */
|
||||
char qc_name[PATH_MAX]; /**< The name of the query classifier to load */
|
||||
char* qc_args; /**< Arguments for the query classifier */
|
||||
QC_CACHE_PROPERTIES qc_cache_properties; /**< The query classifier cache properties. */
|
||||
qc_sql_mode_t qc_sql_mode; /**< The query classifier sql mode */
|
||||
char admin_host[MAX_ADMIN_HOST_LEN]; /**< Admin interface host */
|
||||
uint16_t admin_port; /**< Admin interface port */
|
||||
bool admin_auth; /**< Admin interface authentication */
|
||||
bool admin_enabled; /**< Admin interface is enabled */
|
||||
bool admin_log_auth_failures; /**< Log admin interface authentication failures
|
||||
* */
|
||||
char admin_ssl_key[PATH_MAX]; /**< Admin SSL key */
|
||||
char admin_ssl_cert[PATH_MAX]; /**< Admin SSL cert */
|
||||
char admin_ssl_ca_cert[PATH_MAX]; /**< Admin SSL CA cert */
|
||||
int query_retries; /**< Number of times a interrupted query is
|
||||
* retried */
|
||||
time_t query_retry_timeout; /**< Timeout for query retries */
|
||||
bool substitute_variables; /**< Should environment variables be substituted
|
||||
* */
|
||||
char* local_address; /**< Local address to use when connecting */
|
||||
time_t users_refresh_time; /**< How often the users can be refreshed */
|
||||
uint64_t writeq_high_water; /**< High water mark of dcb write queue */
|
||||
uint64_t writeq_low_water; /**< Low water mark of dcb write queue */
|
||||
char peer_hosts[MAX_ADMIN_HOST_LEN]; /**< The protocol, address and port for peers
|
||||
* (currently only one) */
|
||||
char peer_user[MAX_ADMIN_HOST_LEN]; /**< Username for maxscale-to-maxscale traffic */
|
||||
char peer_password[MAX_ADMIN_HOST_LEN]; /**< Password for maxscale-to-maxscale traffic */
|
||||
mxb_log_target_t log_target; /**< Log type */
|
||||
} MXS_CONFIG;
|
||||
|
||||
/**
|
||||
@ -307,7 +313,7 @@ MXS_CONFIG_PARAMETER* config_get_param(MXS_CONFIG_PARAMETER* params, const char*
|
||||
* @param key Parameter name
|
||||
* @return True if the parameter is an SSL parameter
|
||||
*/
|
||||
bool config_is_ssl_parameter(const char *key);
|
||||
bool config_is_ssl_parameter(const char* key);
|
||||
|
||||
/**
|
||||
* @brief Check if a configuration parameter is valid
|
||||
@ -323,8 +329,10 @@ bool config_is_ssl_parameter(const char *key);
|
||||
*
|
||||
* @return True if the configuration parameter is valid
|
||||
*/
|
||||
bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
|
||||
const char *value, const CONFIG_CONTEXT *context);
|
||||
bool config_param_is_valid(const MXS_MODULE_PARAM* params,
|
||||
const char* key,
|
||||
const char* value,
|
||||
const CONFIG_CONTEXT* context);
|
||||
|
||||
/**
|
||||
* @brief Get a boolean value
|
||||
@ -338,7 +346,7 @@ bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
|
||||
*
|
||||
* @return The value as a boolean or false if none was found
|
||||
*/
|
||||
bool config_get_bool(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
bool config_get_bool(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Get an integer value
|
||||
@ -350,7 +358,7 @@ bool config_get_bool(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
*
|
||||
* @return The integer value of the parameter or 0 if no parameter was found
|
||||
*/
|
||||
int config_get_integer(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
int config_get_integer(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Get a size in bytes
|
||||
@ -366,7 +374,7 @@ int config_get_integer(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
*
|
||||
* @return Number of bytes or 0 if no parameter was found
|
||||
*/
|
||||
uint64_t config_get_size(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
uint64_t config_get_size(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Get a string value
|
||||
@ -376,7 +384,7 @@ uint64_t config_get_size(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
*
|
||||
* @return The raw string value or an empty string if no parameter was found
|
||||
*/
|
||||
const char* config_get_string(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
const char* config_get_string(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Get a enumeration value
|
||||
@ -391,8 +399,9 @@ const char* config_get_string(const MXS_CONFIG_PARAMETER *params, const char *ke
|
||||
* detected. If -1 is used, config_get_param() should be used to detect whether
|
||||
* the parameter exists
|
||||
*/
|
||||
int config_get_enum(const MXS_CONFIG_PARAMETER *params, const char *key,
|
||||
const MXS_ENUM_VALUE *values);
|
||||
int config_get_enum(const MXS_CONFIG_PARAMETER* params,
|
||||
const char* key,
|
||||
const MXS_ENUM_VALUE* values);
|
||||
|
||||
/**
|
||||
* @brief Get a service value
|
||||
@ -402,7 +411,7 @@ int config_get_enum(const MXS_CONFIG_PARAMETER *params, const char *key,
|
||||
*
|
||||
* @return Pointer to configured service
|
||||
*/
|
||||
struct service* config_get_service(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
struct service* config_get_service(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Get a server value
|
||||
@ -412,7 +421,7 @@ struct service* config_get_service(const MXS_CONFIG_PARAMETER *params, const cha
|
||||
*
|
||||
* @return Pointer to configured server
|
||||
*/
|
||||
struct server* config_get_server(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
struct server* config_get_server(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Get an array of servers. The caller should free the produced array,
|
||||
@ -423,7 +432,8 @@ struct server* config_get_server(const MXS_CONFIG_PARAMETER *params, const char
|
||||
* @param output Where to save the output
|
||||
* @return How many servers were found, equal to output array size
|
||||
*/
|
||||
int config_get_server_list(const MXS_CONFIG_PARAMETER *params, const char *key,
|
||||
int config_get_server_list(const MXS_CONFIG_PARAMETER* params,
|
||||
const char* key,
|
||||
struct server*** output);
|
||||
|
||||
/**
|
||||
@ -437,8 +447,9 @@ int config_get_server_list(const MXS_CONFIG_PARAMETER *params, const char *key,
|
||||
* nothing is written. If NULL, the parameter is ignored.
|
||||
* @return Compiled regex code on success, NULL otherwise
|
||||
*/
|
||||
pcre2_code* config_get_compiled_regex(const MXS_CONFIG_PARAMETER *params,
|
||||
const char *key, uint32_t options,
|
||||
pcre2_code* config_get_compiled_regex(const MXS_CONFIG_PARAMETER* params,
|
||||
const char* key,
|
||||
uint32_t options,
|
||||
uint32_t* output_ovec_size);
|
||||
|
||||
/**
|
||||
@ -459,9 +470,11 @@ pcre2_code* config_get_compiled_regex(const MXS_CONFIG_PARAMETER *params,
|
||||
* @return True, if all patterns given by @c keys were successfully compiled.
|
||||
* False otherwise.
|
||||
*/
|
||||
bool config_get_compiled_regexes(const MXS_CONFIG_PARAMETER *params,
|
||||
const char* keys[], int keys_size,
|
||||
uint32_t options, uint32_t* out_ovec_size,
|
||||
bool config_get_compiled_regexes(const MXS_CONFIG_PARAMETER* params,
|
||||
const char* keys[],
|
||||
int keys_size,
|
||||
uint32_t options,
|
||||
uint32_t* out_ovec_size,
|
||||
pcre2_code** out_codes[]);
|
||||
/**
|
||||
* Parse a list of server names and write the results in an array of strings
|
||||
@ -478,7 +491,7 @@ bool config_get_compiled_regexes(const MXS_CONFIG_PARAMETER *params,
|
||||
* @return How many servers were found and set into the array. 0 on error or if
|
||||
* none were found.
|
||||
*/
|
||||
int config_parse_server_list(const char *servers, char ***output_array);
|
||||
int config_parse_server_list(const char* servers, char*** output_array);
|
||||
|
||||
/**
|
||||
* @brief Get copy of parameter value if it is defined
|
||||
@ -494,7 +507,7 @@ int config_parse_server_list(const char *servers, char ***output_array);
|
||||
* @note The use of this function should be avoided after startup as the function
|
||||
* will abort the process if memory allocation fails.
|
||||
*/
|
||||
char* config_copy_string(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
char* config_copy_string(const MXS_CONFIG_PARAMETER* params, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Convert string truth value
|
||||
@ -507,7 +520,7 @@ char* config_copy_string(const MXS_CONFIG_PARAMETER *params, const char *key);
|
||||
* @return 1 if @c value is true, 0 if value is false and -1 if the value is not
|
||||
* a valid truth value
|
||||
*/
|
||||
int config_truth_value(const char *value);
|
||||
int config_truth_value(const char* value);
|
||||
|
||||
/**
|
||||
* @brief Get worker thread count
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/config.h>
|
||||
|
||||
@ -34,5 +34,4 @@ public:
|
||||
private:
|
||||
CONFIG_CONTEXT m_ctx = {(char*)""};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxscale/log.h>
|
||||
@ -29,7 +29,7 @@ namespace maxscale
|
||||
class CustomParser
|
||||
{
|
||||
CustomParser(const CustomParser&);
|
||||
CustomParser& operator = (const CustomParser&);
|
||||
CustomParser& operator=(const CustomParser&);
|
||||
|
||||
public:
|
||||
typedef int32_t token_t;
|
||||
@ -64,7 +64,10 @@ protected:
|
||||
{
|
||||
#ifdef MXS_CP_LOG_UNEXPECTED_AND_EXHAUSTED
|
||||
MXS_NOTICE("Custom parser: In statement '%.*s', unexpected token at '%.*s'.",
|
||||
(int)m_len, m_pSql, (int)(m_pEnd - m_pI), m_pI);
|
||||
(int)m_len,
|
||||
m_pSql,
|
||||
(int)(m_pEnd - m_pI),
|
||||
m_pI);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -102,7 +105,7 @@ protected:
|
||||
*/
|
||||
static bool is_number(char c)
|
||||
{
|
||||
return (c >= '0' && c <= '9');
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,9 +123,8 @@ protected:
|
||||
|
||||
char lc = uc + ('a' - 'A');
|
||||
|
||||
return
|
||||
((m_pI + offset) < m_pEnd) &&
|
||||
((*(m_pI + offset) == uc) || (*(m_pI + offset) == lc));
|
||||
return ((m_pI + offset) < m_pEnd)
|
||||
&& ((*(m_pI + offset) == uc) || (*(m_pI + offset) == lc));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +178,7 @@ protected:
|
||||
static char toupper(char c)
|
||||
{
|
||||
// Significantly faster than library version.
|
||||
return (c >= 'a' && c <='z') ? c - ('a' - 'A') : c;
|
||||
return (c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +213,8 @@ protected:
|
||||
|
||||
if (zWord == pEnd)
|
||||
{
|
||||
if ((pI == m_pEnd) || (!isalpha(*pI))) // Handwritten isalpha not faster than library version.
|
||||
if ((pI == m_pEnd) || (!isalpha(*pI))) // Handwritten isalpha not faster than library
|
||||
// version.
|
||||
{
|
||||
m_pI = pI;
|
||||
}
|
||||
@ -234,5 +237,4 @@ protected:
|
||||
const char* m_pI;
|
||||
const char* m_pEnd;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file dcb.h The Descriptor Control Block
|
||||
@ -45,12 +45,12 @@ struct dcb;
|
||||
*/
|
||||
typedef struct dcbstats
|
||||
{
|
||||
int n_reads; /*< Number of reads on this descriptor */
|
||||
int n_writes; /*< Number of writes on this descriptor */
|
||||
int n_accepts; /*< Number of accepts on this descriptor */
|
||||
int n_buffered; /*< Number of buffered writes */
|
||||
int n_high_water; /*< Number of crosses of high water mark */
|
||||
int n_low_water; /*< Number of crosses of low water mark */
|
||||
int n_reads; /*< Number of reads on this descriptor */
|
||||
int n_writes; /*< Number of writes on this descriptor */
|
||||
int n_accepts; /*< Number of accepts on this descriptor */
|
||||
int n_buffered; /*< Number of buffered writes */
|
||||
int n_high_water; /*< Number of crosses of high water mark */
|
||||
int n_low_water; /*< Number of crosses of low water mark */
|
||||
} DCBSTATS;
|
||||
|
||||
#define DCBSTATS_INIT {0}
|
||||
@ -66,12 +66,29 @@ typedef enum
|
||||
DCB_STATE_NOPOLLING, /*< Removed from poll mask */
|
||||
} dcb_state_t;
|
||||
|
||||
#define STRDCBSTATE(s) ((s) == DCB_STATE_ALLOC ? "DCB_STATE_ALLOC" : \
|
||||
((s) == DCB_STATE_POLLING ? "DCB_STATE_POLLING" : \
|
||||
((s) == DCB_STATE_LISTENING ? "DCB_STATE_LISTENING" : \
|
||||
((s) == DCB_STATE_DISCONNECTED ? "DCB_STATE_DISCONNECTED" : \
|
||||
((s) == DCB_STATE_NOPOLLING ? "DCB_STATE_NOPOLLING" : \
|
||||
((s) == DCB_STATE_UNDEFINED ? "DCB_STATE_UNDEFINED" : "DCB_STATE_UNKNOWN"))))))
|
||||
#define STRDCBSTATE(s) \
|
||||
((s) == DCB_STATE_ALLOC ? "DCB_STATE_ALLOC" \
|
||||
: ((s) == DCB_STATE_POLLING ? "DCB_STATE_POLLING" \
|
||||
: ((s) == DCB_STATE_LISTENING ? "DCB_STATE_LISTENING" \
|
||||
: ((s) \
|
||||
== \
|
||||
DCB_STATE_DISCONNECTED \
|
||||
? \
|
||||
"DCB_STATE_DISCONNECTED" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
DCB_STATE_NOPOLLING \
|
||||
? \
|
||||
"DCB_STATE_NOPOLLING" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
DCB_STATE_UNDEFINED \
|
||||
? \
|
||||
"DCB_STATE_UNDEFINED" \
|
||||
: \
|
||||
"DCB_STATE_UNKNOWN"))))))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -81,16 +98,28 @@ typedef enum
|
||||
DCB_ROLE_INTERNAL /*< Internal DCB not connected to the outside */
|
||||
} dcb_role_t;
|
||||
|
||||
#define STRDCBROLE(r) ((r) == DCB_ROLE_SERVICE_LISTENER ? "DCB_ROLE_SERVICE_LISTENER" : \
|
||||
((r) == DCB_ROLE_CLIENT_HANDLER ? "DCB_ROLE_CLIENT_HANDLER" : \
|
||||
((r) == DCB_ROLE_BACKEND_HANDLER ? "DCB_ROLE_BACKEND_HANDLER" : \
|
||||
((r) == DCB_ROLE_INTERNAL ? "DCB_ROLE_INTERNAL" : \
|
||||
"UNKNOWN DCB ROLE"))))
|
||||
#define STRDCBROLE(r) \
|
||||
((r) == DCB_ROLE_SERVICE_LISTENER ? "DCB_ROLE_SERVICE_LISTENER" \
|
||||
: ((r) == DCB_ROLE_CLIENT_HANDLER ? "DCB_ROLE_CLIENT_HANDLER" \
|
||||
: ((r) \
|
||||
== DCB_ROLE_BACKEND_HANDLER ? \
|
||||
"DCB_ROLE_BACKEND_HANDLER" \
|
||||
: (( \
|
||||
r) \
|
||||
== \
|
||||
DCB_ROLE_INTERNAL \
|
||||
? \
|
||||
"DCB_ROLE_INTERNAL" \
|
||||
: \
|
||||
"UNKNOWN DCB ROLE"))))
|
||||
|
||||
#define DCB_STRTYPE(dcb) (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER ? "Client DCB" : \
|
||||
dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER ? "Backend DCB" : \
|
||||
dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER ? "Listener DCB" : \
|
||||
dcb->dcb_role == DCB_ROLE_INTERNAL ? "Internal DCB" : "Unknown DCB")
|
||||
#define DCB_STRTYPE(dcb) \
|
||||
(dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER ? "Client DCB" \
|
||||
: dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER ? "Backend DCB" \
|
||||
: dcb->dcb_role \
|
||||
== DCB_ROLE_SERVICE_LISTENER ? "Listener DCB" \
|
||||
: \
|
||||
dcb->dcb_role == DCB_ROLE_INTERNAL ? "Internal DCB" : "Unknown DCB")
|
||||
|
||||
/**
|
||||
* Callback reasons for the DCB callback mechanism.
|
||||
@ -111,10 +140,10 @@ typedef enum
|
||||
*/
|
||||
typedef struct dcb_callback
|
||||
{
|
||||
DCB_REASON reason; /*< The reason for the callback */
|
||||
int (*cb)(struct dcb *dcb, DCB_REASON reason, void *userdata);
|
||||
void *userdata; /*< User data to be sent in the callback */
|
||||
struct dcb_callback *next; /*< Next callback for this DCB */
|
||||
DCB_REASON reason; /*< The reason for the callback */
|
||||
int (* cb)(struct dcb* dcb, DCB_REASON reason, void* userdata);
|
||||
void* userdata; /*< User data to be sent in the callback */
|
||||
struct dcb_callback* next; /*< Next callback for this DCB */
|
||||
} DCB_CALLBACK;
|
||||
|
||||
/**
|
||||
@ -145,59 +174,61 @@ typedef enum
|
||||
*/
|
||||
typedef struct dcb
|
||||
{
|
||||
MXB_POLL_DATA poll;
|
||||
bool dcb_errhandle_called; /*< this can be called only once */
|
||||
dcb_role_t dcb_role;
|
||||
int fd; /**< The descriptor */
|
||||
dcb_state_t state; /**< Current descriptor state */
|
||||
SSL_STATE ssl_state; /**< Current state of SSL if in use */
|
||||
int flags; /**< DCB flags */
|
||||
char *remote; /**< Address of remote end */
|
||||
char *user; /**< User name for connection */
|
||||
struct sockaddr_storage ip; /**< remote IPv4/IPv6 address */
|
||||
char *protoname; /**< Name of the protocol */
|
||||
void *protocol; /**< The protocol specific state */
|
||||
size_t protocol_packet_length; /**< How long the protocol specific packet is */
|
||||
size_t protocol_bytes_processed; /**< How many bytes of a packet have been read */
|
||||
struct session *session; /**< The owning session */
|
||||
struct servlistener *listener; /**< For a client DCB, the listener data */
|
||||
MXS_PROTOCOL func; /**< The protocol functions for this descriptor */
|
||||
MXS_AUTHENTICATOR authfunc; /**< The authenticator functions for this descriptor */
|
||||
uint32_t writeqlen; /**< Current number of byes in the write queue */
|
||||
uint32_t high_water; /**< High water mark of write queue */
|
||||
uint32_t low_water; /**< Low water mark of write queue */
|
||||
GWBUF *writeq; /**< Write Data Queue */
|
||||
GWBUF *delayq; /**< Delay Backend Write Data Queue */
|
||||
GWBUF *readq; /**< Read queue for storing incomplete reads */
|
||||
GWBUF *fakeq; /**< Fake event queue for generated events */
|
||||
uint32_t fake_event; /**< Fake event to be delivered to handler */
|
||||
MXB_POLL_DATA poll;
|
||||
bool dcb_errhandle_called; /*< this can be called only once */
|
||||
dcb_role_t dcb_role;
|
||||
int fd; /**< The descriptor */
|
||||
dcb_state_t state; /**< Current descriptor state */
|
||||
SSL_STATE ssl_state; /**< Current state of SSL if in use */
|
||||
int flags; /**< DCB flags */
|
||||
char* remote; /**< Address of remote end */
|
||||
char* user; /**< User name for connection */
|
||||
struct sockaddr_storage ip; /**< remote IPv4/IPv6 address */
|
||||
char* protoname; /**< Name of the protocol */
|
||||
void* protocol; /**< The protocol specific state */
|
||||
size_t protocol_packet_length; /**< How long the protocol specific packet is */
|
||||
size_t protocol_bytes_processed; /**< How many bytes of a packet have been read */
|
||||
struct session* session; /**< The owning session */
|
||||
struct servlistener* listener; /**< For a client DCB, the listener data */
|
||||
MXS_PROTOCOL func; /**< The protocol functions for this descriptor */
|
||||
MXS_AUTHENTICATOR authfunc; /**< The authenticator functions for this descriptor
|
||||
* */
|
||||
uint32_t writeqlen; /**< Current number of byes in the write queue */
|
||||
uint32_t high_water; /**< High water mark of write queue */
|
||||
uint32_t low_water; /**< Low water mark of write queue */
|
||||
GWBUF* writeq; /**< Write Data Queue */
|
||||
GWBUF* delayq; /**< Delay Backend Write Data Queue */
|
||||
GWBUF* readq; /**< Read queue for storing incomplete reads */
|
||||
GWBUF* fakeq; /**< Fake event queue for generated events */
|
||||
uint32_t fake_event; /**< Fake event to be delivered to handler */
|
||||
|
||||
DCBSTATS stats; /**< DCB related statistics */
|
||||
struct dcb *nextpersistent; /**< Next DCB in the persistent pool for SERVER */
|
||||
time_t persistentstart; /**< 0: Not in the persistent pool.
|
||||
-1: Evicted from the persistent pool and being closed.
|
||||
non-0: Time when placed in the persistent pool.
|
||||
*/
|
||||
struct service *service; /**< The related service */
|
||||
void *data; /**< Specific client data, shared between DCBs of this session */
|
||||
void *authenticator_data; /**< The authenticator data for this DCB */
|
||||
DCB_CALLBACK *callbacks; /**< The list of callbacks for the DCB */
|
||||
int64_t last_read; /*< Last time the DCB received data */
|
||||
struct server *server; /**< The associated backend server */
|
||||
SSL* ssl; /*< SSL struct for connection */
|
||||
bool ssl_read_want_read; /*< Flag */
|
||||
DCBSTATS stats; /**< DCB related statistics */
|
||||
struct dcb* nextpersistent; /**< Next DCB in the persistent pool for SERVER */
|
||||
time_t persistentstart; /**< 0: Not in the persistent pool.
|
||||
* -1: Evicted from the persistent pool and being closed.
|
||||
* non-0: Time when placed in the persistent pool.
|
||||
*/
|
||||
struct service* service; /**< The related service */
|
||||
void* data; /**< Specific client data, shared between DCBs of this session */
|
||||
void* authenticator_data; /**< The authenticator data for this DCB */
|
||||
DCB_CALLBACK* callbacks; /**< The list of callbacks for the DCB */
|
||||
int64_t last_read; /*< Last time the DCB received data */
|
||||
struct server* server; /**< The associated backend server */
|
||||
SSL* ssl; /*< SSL struct for connection */
|
||||
bool ssl_read_want_read; /*< Flag */
|
||||
bool ssl_read_want_write; /*< Flag */
|
||||
bool ssl_write_want_read; /*< Flag */
|
||||
bool ssl_write_want_write; /*< Flag */
|
||||
bool was_persistent; /**< Whether this DCB was in the persistent pool */
|
||||
bool high_water_reached; /** High water mark reached, to determine whether need release throttle */
|
||||
bool ssl_write_want_write; /*< Flag */
|
||||
bool was_persistent; /**< Whether this DCB was in the persistent pool */
|
||||
bool high_water_reached; /** High water mark reached, to determine whether need release
|
||||
* throttle */
|
||||
struct
|
||||
{
|
||||
struct dcb *next; /**< Next DCB in owning thread's list */
|
||||
struct dcb *tail; /**< Last DCB in owning thread's list */
|
||||
} thread;
|
||||
uint32_t n_close; /** How many times dcb_close has been called. */
|
||||
char *path; /** If a Unix socket, the path it was bound to. */
|
||||
struct dcb* next; /**< Next DCB in owning thread's list */
|
||||
struct dcb* tail; /**< Last DCB in owning thread's list */
|
||||
} thread;
|
||||
uint32_t n_close; /** How many times dcb_close has been called. */
|
||||
char* path; /** If a Unix socket, the path it was bound to. */
|
||||
} DCB;
|
||||
|
||||
/**
|
||||
@ -213,14 +244,14 @@ typedef enum
|
||||
} DCB_USAGE;
|
||||
|
||||
/* A few useful macros */
|
||||
#define DCB_SESSION(x) (x)->session
|
||||
#define DCB_PROTOCOL(x, type) (type *)((x)->protocol)
|
||||
#define DCB_WRITEQLEN(x) (x)->writeqlen
|
||||
#define DCB_SET_LOW_WATER(x, lo) (x)->low_water = (lo);
|
||||
#define DCB_SET_HIGH_WATER(x, hi) (x)->low_water = (hi);
|
||||
#define DCB_BELOW_LOW_WATER(x) ((x)->low_water && (x)->writeqlen < (x)->low_water)
|
||||
#define DCB_ABOVE_HIGH_WATER(x) ((x)->high_water && (x)->writeqlen > (x)->high_water)
|
||||
#define DCB_THROTTLING_ENABLED(x) ((x)->high_water && (x)->low_water)
|
||||
#define DCB_SESSION(x) (x)->session
|
||||
#define DCB_PROTOCOL(x, type) (type*)((x)->protocol)
|
||||
#define DCB_WRITEQLEN(x) (x)->writeqlen
|
||||
#define DCB_SET_LOW_WATER(x, lo) (x)->low_water = (lo);
|
||||
#define DCB_SET_HIGH_WATER(x, hi) (x)->low_water = (hi);
|
||||
#define DCB_BELOW_LOW_WATER(x) ((x)->low_water && (x)->writeqlen < (x)->low_water)
|
||||
#define DCB_ABOVE_HIGH_WATER(x) ((x)->high_water && (x)->writeqlen > (x)->high_water)
|
||||
#define DCB_THROTTLING_ENABLED(x) ((x)->high_water && (x)->low_water)
|
||||
/**
|
||||
* @brief DCB system initialization function
|
||||
*
|
||||
@ -228,13 +259,13 @@ typedef enum
|
||||
*/
|
||||
void dcb_global_init();
|
||||
|
||||
int dcb_write(DCB *, GWBUF *);
|
||||
DCB *dcb_accept(DCB *listener);
|
||||
DCB *dcb_alloc(dcb_role_t, struct servlistener *);
|
||||
DCB *dcb_connect(struct server *, struct session *, const char *);
|
||||
int dcb_read(DCB *, GWBUF **, int);
|
||||
int dcb_drain_writeq(DCB *);
|
||||
void dcb_close(DCB *);
|
||||
int dcb_write(DCB*, GWBUF*);
|
||||
DCB* dcb_accept(DCB* listener);
|
||||
DCB* dcb_alloc(dcb_role_t, struct servlistener*);
|
||||
DCB* dcb_connect(struct server*, struct session*, const char*);
|
||||
int dcb_read(DCB*, GWBUF**, int);
|
||||
int dcb_drain_writeq(DCB*);
|
||||
void dcb_close(DCB*);
|
||||
|
||||
/**
|
||||
* @brief Close DCB in the thread that owns it.
|
||||
@ -244,30 +275,35 @@ void dcb_close(DCB *);
|
||||
* @note Even if the calling thread owns the dcb, the closing will
|
||||
* still be made via the event loop.
|
||||
*/
|
||||
void dcb_close_in_owning_thread(DCB *dcb);
|
||||
void dcb_close_in_owning_thread(DCB* dcb);
|
||||
|
||||
void printAllDCBs(); /* Debug to print all DCB in the system */
|
||||
void printDCB(DCB *); /* Debug print routine */
|
||||
void dprintDCBList(DCB *); /* Debug print DCB list statistics */
|
||||
void dprintAllDCBs(DCB *); /* Debug to print all DCB in the system */
|
||||
void dprintOneDCB(DCB *, DCB *); /* Debug to print one DCB */
|
||||
void dprintDCB(DCB *, DCB *); /* Debug to print a DCB in the system */
|
||||
void dListDCBs(DCB *); /* List all DCBs in the system */
|
||||
void dListClients(DCB *); /* List al the client DCBs */
|
||||
const char *gw_dcb_state2string(dcb_state_t); /* DCB state to string */
|
||||
void dcb_printf(DCB *, const char *, ...) __attribute__((format(printf, 2, 3))); /* DCB version of printf */
|
||||
int dcb_add_callback(DCB *, DCB_REASON, int (*)(struct dcb *, DCB_REASON, void *), void *);
|
||||
int dcb_remove_callback(DCB *, DCB_REASON, int (*)(struct dcb *, DCB_REASON, void *), void *);
|
||||
int dcb_count_by_usage(DCB_USAGE); /* Return counts of DCBs */
|
||||
int dcb_persistent_clean_count(DCB *, int, bool); /* Clean persistent and return count */
|
||||
void dcb_hangup_foreach (struct server* server);
|
||||
void printAllDCBs(); /* Debug to print all DCB in
|
||||
* the system */
|
||||
void printDCB(DCB*); /* Debug print routine */
|
||||
void dprintDCBList(DCB*); /* Debug print DCB list
|
||||
* statistics */
|
||||
void dprintAllDCBs(DCB*); /* Debug to print all DCB in
|
||||
* the system */
|
||||
void dprintOneDCB(DCB*, DCB*); /* Debug to print one DCB */
|
||||
void dprintDCB(DCB*, DCB*); /* Debug to print a DCB in the
|
||||
* system */
|
||||
void dListDCBs(DCB*); /* List all DCBs in the system
|
||||
* */
|
||||
void dListClients(DCB*); /* List al the client DCBs */
|
||||
const char* gw_dcb_state2string(dcb_state_t); /* DCB state to string */
|
||||
void dcb_printf(DCB*, const char*, ...) __attribute__ ((format(printf, 2, 3))); /* DCB version of printf */
|
||||
int dcb_add_callback(DCB*, DCB_REASON, int (*)(struct dcb*, DCB_REASON, void*), void*);
|
||||
int dcb_remove_callback(DCB*, DCB_REASON, int (*)(struct dcb*, DCB_REASON, void*), void*);
|
||||
int dcb_count_by_usage(DCB_USAGE); /* Return counts of DCBs */
|
||||
int dcb_persistent_clean_count(DCB*, int, bool); /* Clean persistent and return count */
|
||||
void dcb_hangup_foreach(struct server* server);
|
||||
uint64_t dcb_get_session_id(DCB* dcb);
|
||||
char *dcb_role_name(DCB *); /* Return the name of a role */
|
||||
int dcb_accept_SSL(DCB* dcb);
|
||||
int dcb_connect_SSL(DCB* dcb);
|
||||
int dcb_listen(DCB *listener, const char *config, const char *protocol_name);
|
||||
void dcb_enable_session_timeouts();
|
||||
void dcb_process_idle_sessions(int thr);
|
||||
char* dcb_role_name(DCB*); /* Return the name of a role */
|
||||
int dcb_accept_SSL(DCB* dcb);
|
||||
int dcb_connect_SSL(DCB* dcb);
|
||||
int dcb_listen(DCB* listener, const char* config, const char* protocol_name);
|
||||
void dcb_enable_session_timeouts();
|
||||
void dcb_process_idle_sessions(int thr);
|
||||
|
||||
/**
|
||||
* @brief Append a buffer the DCB's readqueue
|
||||
@ -278,7 +314,7 @@ void dcb_process_idle_sessions(int thr);
|
||||
* @param dcb The DCB to be appended to.
|
||||
* @param buffer The buffer to append.
|
||||
*/
|
||||
static inline void dcb_readq_append(DCB *dcb, GWBUF *buffer)
|
||||
static inline void dcb_readq_append(DCB* dcb, GWBUF* buffer)
|
||||
{
|
||||
dcb->readq = gwbuf_append(dcb->readq, buffer);
|
||||
}
|
||||
@ -321,7 +357,7 @@ static unsigned int dcb_readq_length(DCB* dcb)
|
||||
* @param dcb The DCB to be prepended to.
|
||||
* @param buffer The buffer to prepend
|
||||
*/
|
||||
static inline void dcb_readq_prepend(DCB *dcb, GWBUF *buffer)
|
||||
static inline void dcb_readq_prepend(DCB* dcb, GWBUF* buffer)
|
||||
{
|
||||
dcb->readq = gwbuf_append(buffer, dcb->readq);
|
||||
}
|
||||
@ -349,7 +385,7 @@ static GWBUF* dcb_readq_release(DCB* dcb)
|
||||
* @param dcb The DCB to be reset.
|
||||
* @param buffer The buffer to reset with
|
||||
*/
|
||||
static inline void dcb_readq_set(DCB *dcb, GWBUF *buffer)
|
||||
static inline void dcb_readq_set(DCB* dcb, GWBUF* buffer)
|
||||
{
|
||||
if (dcb->readq)
|
||||
{
|
||||
@ -377,7 +413,7 @@ static inline void dcb_readq_set(DCB *dcb, GWBUF *buffer)
|
||||
* @param data User provided data passed as the second parameter to @c func
|
||||
* @return True if all DCBs were iterated, false if the callback returned false
|
||||
*/
|
||||
bool dcb_foreach(bool (*func)(DCB *dcb, void *data), void *data);
|
||||
bool dcb_foreach(bool (* func)(DCB* dcb, void* data), void* data);
|
||||
|
||||
/**
|
||||
* @brief Call a function for each connected DCB on the current worker
|
||||
@ -388,7 +424,7 @@ bool dcb_foreach(bool (*func)(DCB *dcb, void *data), void *data);
|
||||
*
|
||||
* @param data User provided data passed as the second parameter to @c func
|
||||
*/
|
||||
void dcb_foreach_local(bool (*func)(DCB *dcb, void *data), void *data);
|
||||
void dcb_foreach_local(bool (* func)(DCB* dcb, void* data), void* data);
|
||||
|
||||
/**
|
||||
* @brief Return the port number this DCB is connected to
|
||||
@ -396,7 +432,7 @@ void dcb_foreach_local(bool (*func)(DCB *dcb, void *data), void *data);
|
||||
* @param dcb DCB to inspect
|
||||
* @return Port number the DCB is connected to or -1 if information is not available
|
||||
*/
|
||||
int dcb_get_port(const DCB *dcb);
|
||||
int dcb_get_port(const DCB* dcb);
|
||||
|
||||
/**
|
||||
* @brief Return the DCB currently being handled by the calling thread.
|
||||
@ -418,8 +454,8 @@ json_t* dcb_to_json(DCB* dcb);
|
||||
/**
|
||||
* DCB flags values
|
||||
*/
|
||||
#define DCBF_HUNG 0x0002 /*< Hangup has been dispatched */
|
||||
#define DCBF_REPLIED 0x0004 /*< DCB was written to */
|
||||
#define DCBF_HUNG 0x0002 /*< Hangup has been dispatched */
|
||||
#define DCBF_REPLIED 0x0004 /*< DCB was written to */
|
||||
|
||||
#define DCB_REPLIED(d) ((d)->flags & DCBF_REPLIED)
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
@ -20,8 +20,8 @@ MXS_BEGIN_DECLS
|
||||
|
||||
|
||||
EVP_CIPHER_CTX* mxs_evp_cipher_ctx_alloc();
|
||||
void mxs_evp_cipher_ctx_free(EVP_CIPHER_CTX* ctx);
|
||||
uint8_t* mxs_evp_cipher_ctx_buf(EVP_CIPHER_CTX* ctx);
|
||||
uint8_t* mxs_evp_cipher_ctx_oiv(EVP_CIPHER_CTX* ctx);
|
||||
void mxs_evp_cipher_ctx_free(EVP_CIPHER_CTX* ctx);
|
||||
uint8_t* mxs_evp_cipher_ctx_buf(EVP_CIPHER_CTX* ctx);
|
||||
uint8_t* mxs_evp_cipher_ctx_oiv(EVP_CIPHER_CTX* ctx);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <syslog.h>
|
||||
@ -62,13 +62,13 @@ namespace event
|
||||
|
||||
enum id_t
|
||||
{
|
||||
AUTHENTICATION_FAILURE /**< Authentication failure */
|
||||
AUTHENTICATION_FAILURE /**< Authentication failure */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DEFAULT_FACILITY = LOG_USER,
|
||||
DEFAULT_LEVEL = LOG_WARNING
|
||||
DEFAULT_LEVEL = LOG_WARNING
|
||||
};
|
||||
|
||||
/**
|
||||
@ -155,11 +155,12 @@ int32_t get_log_level(id_t id);
|
||||
*/
|
||||
void log(id_t event_id,
|
||||
const char* modname,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...) mxs_attribute((format(printf, 6, 7)));
|
||||
|
||||
const char* file,
|
||||
int line,
|
||||
const char* function,
|
||||
const char* format,
|
||||
...) mxs_attribute((format(printf, 6, 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,5 +171,5 @@ void log(id_t event_id,
|
||||
* @param ... Formatting string specific additional arguments.
|
||||
*
|
||||
*/
|
||||
#define MXS_LOG_EVENT(event_id, format, ...)\
|
||||
#define MXS_LOG_EVENT(event_id, format, ...) \
|
||||
maxscale::event::log(event_id, MXS_MODULE_NAME, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/filter.h - The public filter interface
|
||||
@ -88,7 +88,7 @@ typedef struct mxs_filter_object
|
||||
*
|
||||
* @return New filter instance on NULL on error
|
||||
*/
|
||||
MXS_FILTER *(*createInstance)(const char *name, MXS_CONFIG_PARAMETER *params);
|
||||
MXS_FILTER*(*createInstance)(const char* name, MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
/**
|
||||
* Called to create a new user session within the filter
|
||||
@ -103,7 +103,7 @@ typedef struct mxs_filter_object
|
||||
*
|
||||
* @return New filter session or NULL on error
|
||||
*/
|
||||
MXS_FILTER_SESSION *(*newSession)(MXS_FILTER *instance, MXS_SESSION *session);
|
||||
MXS_FILTER_SESSION*(*newSession)(MXS_FILTER * instance, MXS_SESSION* session);
|
||||
|
||||
/**
|
||||
* @brief Called when a session is closed
|
||||
@ -113,7 +113,7 @@ typedef struct mxs_filter_object
|
||||
* @param instance Filter instance
|
||||
* @param fsession Filter session
|
||||
*/
|
||||
void (*closeSession)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession);
|
||||
void (* closeSession)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession);
|
||||
|
||||
/**
|
||||
* @brief Called when a session is freed
|
||||
@ -123,7 +123,7 @@ typedef struct mxs_filter_object
|
||||
* @param instance Filter instance
|
||||
* @param fsession Filter session
|
||||
*/
|
||||
void (*freeSession)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession);
|
||||
void (* freeSession)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession);
|
||||
|
||||
/**
|
||||
* @brief Sets the downstream component of the filter pipeline
|
||||
@ -131,7 +131,7 @@ typedef struct mxs_filter_object
|
||||
* @param instance Filter instance
|
||||
* @param fsession Filter session
|
||||
*/
|
||||
void (*setDownstream)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession, MXS_DOWNSTREAM *downstream);
|
||||
void (* setDownstream)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, MXS_DOWNSTREAM* downstream);
|
||||
|
||||
/**
|
||||
* @brief Sets the upstream component of the filter pipeline
|
||||
@ -139,7 +139,7 @@ typedef struct mxs_filter_object
|
||||
* @param instance Filter instance
|
||||
* @param fsession Filter session
|
||||
*/
|
||||
void (*setUpstream)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession, MXS_UPSTREAM *downstream);
|
||||
void (* setUpstream)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, MXS_UPSTREAM* downstream);
|
||||
|
||||
/**
|
||||
* @brief Called on each query that requires routing
|
||||
@ -153,7 +153,7 @@ typedef struct mxs_filter_object
|
||||
* @return If successful, the function returns 1. If an error occurs
|
||||
* and the session should be closed, the function returns 0.
|
||||
*/
|
||||
int32_t (*routeQuery)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession, GWBUF *queue);
|
||||
int32_t (* routeQuery)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, GWBUF* queue);
|
||||
|
||||
/**
|
||||
* @brief Called for each reply packet
|
||||
@ -167,7 +167,7 @@ typedef struct mxs_filter_object
|
||||
* @return If successful, the function returns 1. If an error occurs
|
||||
* and the session should be closed, the function returns 0.
|
||||
*/
|
||||
int32_t (*clientReply)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession, GWBUF *queue);
|
||||
int32_t (* clientReply)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, GWBUF* queue);
|
||||
|
||||
/**
|
||||
* @brief Called for diagnostic output
|
||||
@ -176,7 +176,7 @@ typedef struct mxs_filter_object
|
||||
* @param fsession Filter session, NULL if general information about the filter is queried
|
||||
* @param dcb DCB where the diagnostic information should be written
|
||||
*/
|
||||
void (*diagnostics)(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession, DCB *dcb);
|
||||
void (* diagnostics)(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, DCB* dcb);
|
||||
|
||||
/**
|
||||
* @brief Called for diagnostic output
|
||||
@ -188,7 +188,7 @@ typedef struct mxs_filter_object
|
||||
*
|
||||
* @see jansson.h
|
||||
*/
|
||||
json_t* (*diagnostics_json)(const MXS_FILTER *instance, const MXS_FILTER_SESSION *fsession);
|
||||
json_t* (*diagnostics_json)(const MXS_FILTER * instance, const MXS_FILTER_SESSION* fsession);
|
||||
|
||||
/**
|
||||
* @brief Called to obtain the capabilities of the filter
|
||||
@ -197,15 +197,14 @@ typedef struct mxs_filter_object
|
||||
*
|
||||
* @see routing.h
|
||||
*/
|
||||
uint64_t (*getCapabilities)(MXS_FILTER *instance);
|
||||
uint64_t (* getCapabilities)(MXS_FILTER* instance);
|
||||
|
||||
/**
|
||||
* @brief Called for destroying a filter instance
|
||||
*
|
||||
* @param instance Filter instance
|
||||
*/
|
||||
void (*destroyInstance)(MXS_FILTER *instance);
|
||||
|
||||
void (* destroyInstance)(MXS_FILTER* instance);
|
||||
} MXS_FILTER_OBJECT;
|
||||
|
||||
/**
|
||||
@ -213,7 +212,7 @@ typedef struct mxs_filter_object
|
||||
* is changed these values must be updated in line with the rules in the
|
||||
* file modinfo.h.
|
||||
*/
|
||||
#define MXS_FILTER_VERSION {4, 0, 0}
|
||||
#define MXS_FILTER_VERSION {4, 0, 0}
|
||||
|
||||
/**
|
||||
* MXS_FILTER_DEF represents a filter definition from the configuration file.
|
||||
@ -263,7 +262,7 @@ MXS_FILTER* filter_def_get_instance(const MXS_FILTER_DEF* filter_def);
|
||||
|
||||
typedef enum filter_capability
|
||||
{
|
||||
FCAP_TYPE_NONE = 0x0 // TODO: remove once filter capabilities are defined
|
||||
FCAP_TYPE_NONE = 0x0 // TODO: remove once filter capabilities are defined
|
||||
} filter_capability_t;
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxscale/filter.h>
|
||||
@ -48,7 +48,8 @@ public:
|
||||
|
||||
Downstream(const MXS_DOWNSTREAM& down)
|
||||
: m_data(down)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for sending a packet from the client to the next component
|
||||
@ -83,7 +84,8 @@ public:
|
||||
|
||||
Upstream(const MXS_UPSTREAM& up)
|
||||
: m_data(up)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for sending a packet from the backend to the next component
|
||||
@ -147,7 +149,7 @@ public:
|
||||
*
|
||||
* @param pDcb The dcb where the diagnostics should be written.
|
||||
*/
|
||||
void diagnostics(DCB *pDcb);
|
||||
void diagnostics(DCB* pDcb);
|
||||
|
||||
/**
|
||||
* Called for obtaining diagnostics about the filter session.
|
||||
@ -170,9 +172,9 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
MXS_SESSION* m_pSession; /*< The MXS_SESSION this filter session is associated with. */
|
||||
Downstream m_down; /*< The downstream component. */
|
||||
Upstream m_up; /*< The upstream component. */
|
||||
MXS_SESSION* m_pSession; /*< The MXS_SESSION this filter session is associated with. */
|
||||
Downstream m_down; /*< The downstream component. */
|
||||
Upstream m_up; /*< The upstream component. */
|
||||
};
|
||||
|
||||
|
||||
@ -373,5 +375,4 @@ MXS_FILTER_OBJECT Filter<FilterType, FilterSessionType>::s_object =
|
||||
&Filter<FilterType, FilterSessionType>::getCapabilities,
|
||||
&Filter<FilterType, FilterSessionType>::destroyInstance,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file hint.h The generic hint data that may be attached to buffers
|
||||
@ -28,19 +28,43 @@ typedef enum
|
||||
HINT_ROUTE_TO_MASTER = 1,
|
||||
HINT_ROUTE_TO_SLAVE,
|
||||
HINT_ROUTE_TO_NAMED_SERVER,
|
||||
HINT_ROUTE_TO_UPTODATE_SERVER, /*< not supported by RWSplit and HintRouter */
|
||||
HINT_ROUTE_TO_ALL, /*< not supported by RWSplit, supported by HintRouter */
|
||||
HINT_ROUTE_TO_UPTODATE_SERVER, /*< not supported by RWSplit and HintRouter */
|
||||
HINT_ROUTE_TO_ALL, /*< not supported by RWSplit, supported by HintRouter */
|
||||
HINT_ROUTE_TO_LAST_USED,
|
||||
HINT_PARAMETER
|
||||
} HINT_TYPE;
|
||||
|
||||
#define STRHINTTYPE(t) (t == HINT_ROUTE_TO_MASTER ? "HINT_ROUTE_TO_MASTER" : \
|
||||
((t) == HINT_ROUTE_TO_SLAVE ? "HINT_ROUTE_TO_SLAVE" : \
|
||||
((t) == HINT_ROUTE_TO_NAMED_SERVER ? "HINT_ROUTE_TO_NAMED_SERVER" : \
|
||||
((t) == HINT_ROUTE_TO_UPTODATE_SERVER ? "HINT_ROUTE_TO_UPTODATE_SERVER" : \
|
||||
((t) == HINT_ROUTE_TO_ALL ? "HINT_ROUTE_TO_ALL" : \
|
||||
((t) == HINT_ROUTE_TO_LAST_USED ? "HINT_ROUTE_TO_LAST_USED" :\
|
||||
((t) == HINT_PARAMETER ? "HINT_PARAMETER" : "UNKNOWN HINT TYPE")))))))
|
||||
#define STRHINTTYPE(t) \
|
||||
(t == HINT_ROUTE_TO_MASTER ? "HINT_ROUTE_TO_MASTER" \
|
||||
: ((t) == HINT_ROUTE_TO_SLAVE ? "HINT_ROUTE_TO_SLAVE" \
|
||||
: ((t) \
|
||||
== HINT_ROUTE_TO_NAMED_SERVER ? \
|
||||
"HINT_ROUTE_TO_NAMED_SERVER" \
|
||||
: ((t) \
|
||||
== \
|
||||
HINT_ROUTE_TO_UPTODATE_SERVER \
|
||||
? \
|
||||
"HINT_ROUTE_TO_UPTODATE_SERVER" \
|
||||
: (( \
|
||||
t) \
|
||||
== \
|
||||
HINT_ROUTE_TO_ALL \
|
||||
? \
|
||||
"HINT_ROUTE_TO_ALL" \
|
||||
: (( \
|
||||
t) \
|
||||
== \
|
||||
HINT_ROUTE_TO_LAST_USED \
|
||||
? \
|
||||
"HINT_ROUTE_TO_LAST_USED" \
|
||||
: (( \
|
||||
t) \
|
||||
== \
|
||||
HINT_PARAMETER \
|
||||
? \
|
||||
"HINT_PARAMETER" \
|
||||
: \
|
||||
"UNKNOWN HINT TYPE")))))))
|
||||
|
||||
/**
|
||||
* A generic hint.
|
||||
@ -51,19 +75,19 @@ typedef enum
|
||||
*/
|
||||
typedef struct hint
|
||||
{
|
||||
HINT_TYPE type; /*< The Type of hint */
|
||||
void *data; /*< Type specific data */
|
||||
void *value; /*< Parameter value for hint */
|
||||
unsigned int dsize; /*< Size of the hint data */
|
||||
struct hint *next; /*< Another hint for this buffer */
|
||||
HINT_TYPE type; /*< The Type of hint */
|
||||
void* data; /*< Type specific data */
|
||||
void* value; /*< Parameter value for hint */
|
||||
unsigned int dsize; /*< Size of the hint data */
|
||||
struct hint* next; /*< Another hint for this buffer */
|
||||
} HINT;
|
||||
|
||||
HINT *hint_alloc(HINT_TYPE, void *, unsigned int);
|
||||
HINT *hint_create_parameter(HINT *, char *, const char *);
|
||||
HINT *hint_create_route(HINT *, HINT_TYPE, const char *);
|
||||
HINT *hint_splice(HINT *head, HINT *list);
|
||||
void hint_free(HINT *);
|
||||
HINT *hint_dup(const HINT *);
|
||||
bool hint_exists(HINT **, HINT_TYPE);
|
||||
HINT* hint_alloc(HINT_TYPE, void*, unsigned int);
|
||||
HINT* hint_create_parameter(HINT*, char*, const char*);
|
||||
HINT* hint_create_route(HINT*, HINT_TYPE, const char*);
|
||||
HINT* hint_splice(HINT* head, HINT* list);
|
||||
void hint_free(HINT*);
|
||||
HINT* hint_dup(const HINT*);
|
||||
bool hint_exists(HINT * *, HINT_TYPE);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file housekeeper.h A mechanism to have task run periodically
|
||||
@ -30,7 +30,7 @@ MXS_BEGIN_DECLS
|
||||
* executed again at a later point in time. If the function returns false,
|
||||
* the task is removed.
|
||||
*/
|
||||
typedef bool (*TASKFN)(void *data);
|
||||
typedef bool (* TASKFN)(void* data);
|
||||
|
||||
/**
|
||||
* Initialises the housekeeper mechanism.
|
||||
@ -70,21 +70,21 @@ void hkfinish();
|
||||
* @param data Data passed to function as the parameter
|
||||
* @param frequency Frequency of execution
|
||||
*/
|
||||
void hktask_add(const char *name, TASKFN func, void *data, int frequency);
|
||||
void hktask_add(const char* name, TASKFN func, void* data, int frequency);
|
||||
|
||||
/**
|
||||
* @brief Remove all tasks with this name
|
||||
*
|
||||
* @param name Task name
|
||||
*/
|
||||
void hktask_remove(const char *name);
|
||||
void hktask_remove(const char* name);
|
||||
|
||||
/**
|
||||
* @brief Show the tasks that are scheduled for the house keeper
|
||||
*
|
||||
* @param pDcb The DCB to send to output
|
||||
*/
|
||||
void hkshow_tasks(DCB *pdcb);
|
||||
void hkshow_tasks(DCB* pdcb);
|
||||
|
||||
/**
|
||||
* @brief Show tasks as JSON resource
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -26,7 +26,7 @@ static inline std::string http_get_date()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
struct tm tm;
|
||||
char buf[200]; // Enough to store all dates
|
||||
char buf[200]; // Enough to store all dates
|
||||
|
||||
gmtime_r(&now, &tm);
|
||||
strftime(buf, sizeof(buf), "%a, %d %b %y %T GMT", &tm);
|
||||
@ -44,7 +44,7 @@ static inline std::string http_get_date()
|
||||
static inline std::string http_to_date(time_t t)
|
||||
{
|
||||
struct tm tm;
|
||||
char buf[200]; // Enough to store all dates
|
||||
char buf[200]; // Enough to store all dates
|
||||
|
||||
gmtime_r(&t, &tm);
|
||||
strftime(buf, sizeof(buf), "%a, %d %b %Y %T GMT", &tm);
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -33,7 +33,6 @@ struct default_delete<json_t>
|
||||
json_decref(pJson);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace maxscale
|
||||
@ -99,10 +98,8 @@ static inline std::string json_to_string(json_t* json)
|
||||
default:
|
||||
mxb_assert(false);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file Helper functions for creating JSON API conforming objects
|
||||
@ -24,19 +24,19 @@
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
/** Resource endpoints */
|
||||
#define MXS_JSON_API_SERVERS "/servers/"
|
||||
#define MXS_JSON_API_SERVICES "/services/"
|
||||
#define MXS_JSON_API_FILTERS "/filters/"
|
||||
#define MXS_JSON_API_MONITORS "/monitors/"
|
||||
#define MXS_JSON_API_SESSIONS "/sessions/"
|
||||
#define MXS_JSON_API_MAXSCALE "/maxscale/"
|
||||
#define MXS_JSON_API_THREADS "/maxscale/threads/"
|
||||
#define MXS_JSON_API_LOGS "/maxscale/logs/"
|
||||
#define MXS_JSON_API_TASKS "/maxscale/tasks/"
|
||||
#define MXS_JSON_API_MODULES "/maxscale/modules/"
|
||||
#define MXS_JSON_API_QC_STATS "/maxscale/qc_stats/"
|
||||
#define MXS_JSON_API_QC "/maxscale/query_classifier/"
|
||||
#define MXS_JSON_API_USERS "/users/"
|
||||
#define MXS_JSON_API_SERVERS "/servers/"
|
||||
#define MXS_JSON_API_SERVICES "/services/"
|
||||
#define MXS_JSON_API_FILTERS "/filters/"
|
||||
#define MXS_JSON_API_MONITORS "/monitors/"
|
||||
#define MXS_JSON_API_SESSIONS "/sessions/"
|
||||
#define MXS_JSON_API_MAXSCALE "/maxscale/"
|
||||
#define MXS_JSON_API_THREADS "/maxscale/threads/"
|
||||
#define MXS_JSON_API_LOGS "/maxscale/logs/"
|
||||
#define MXS_JSON_API_TASKS "/maxscale/tasks/"
|
||||
#define MXS_JSON_API_MODULES "/maxscale/modules/"
|
||||
#define MXS_JSON_API_QC_STATS "/maxscale/qc_stats/"
|
||||
#define MXS_JSON_API_QC "/maxscale/query_classifier/"
|
||||
#define MXS_JSON_API_USERS "/users/"
|
||||
|
||||
/**
|
||||
* @brief Create a JSON object
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file limits.h
|
||||
@ -42,14 +42,14 @@ MXS_BEGIN_DECLS
|
||||
*
|
||||
* The value used when setting SO_RCVBUF of client sockets.
|
||||
*/
|
||||
#define MXS_CLIENT_SO_RCVBUF (128 * 1024)
|
||||
#define MXS_CLIENT_SO_RCVBUF (128 * 1024)
|
||||
|
||||
/**
|
||||
* MXS_CLIENT_SO_SNDBUF
|
||||
*
|
||||
* The value used when setting SO_SNDBUF of client sockets.
|
||||
*/
|
||||
#define MXS_CLIENT_SO_SNDBUF (128 * 1024)
|
||||
#define MXS_CLIENT_SO_SNDBUF (128 * 1024)
|
||||
|
||||
/**
|
||||
* MXS_MAX_NW_READ_BUFFER_SIZE
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file listener.h
|
||||
@ -34,21 +34,22 @@ struct service;
|
||||
*/
|
||||
typedef struct servlistener
|
||||
{
|
||||
char *name; /**< Name of the listener */
|
||||
char *protocol; /**< Protocol module to load */
|
||||
unsigned short port; /**< Port to listen on */
|
||||
char *address; /**< Address to listen with */
|
||||
char *authenticator; /**< Name of authenticator */
|
||||
char *auth_options; /**< Authenticator options */
|
||||
void *auth_instance; /**< Authenticator instance created in MXS_AUTHENTICATOR::initialize() */
|
||||
SSL_LISTENER *ssl; /**< Structure of SSL data or NULL */
|
||||
struct dcb *listener; /**< The DCB for the listener */
|
||||
struct users *users; /**< The user data for this listener */
|
||||
struct service* service; /**< The service which used by this listener */
|
||||
SPINLOCK lock;
|
||||
int active; /**< True if the port has not been deleted */
|
||||
struct servlistener *next; /**< Next service protocol */
|
||||
} SERV_LISTENER; // TODO: Rename to LISTENER
|
||||
char* name; /**< Name of the listener */
|
||||
char* protocol; /**< Protocol module to load */
|
||||
unsigned short port; /**< Port to listen on */
|
||||
char* address; /**< Address to listen with */
|
||||
char* authenticator;/**< Name of authenticator */
|
||||
char* auth_options; /**< Authenticator options */
|
||||
void* auth_instance;/**< Authenticator instance created in MXS_AUTHENTICATOR::initialize()
|
||||
* */
|
||||
SSL_LISTENER* ssl; /**< Structure of SSL data or NULL */
|
||||
struct dcb* listener; /**< The DCB for the listener */
|
||||
struct users* users; /**< The user data for this listener */
|
||||
struct service* service; /**< The service which used by this listener */
|
||||
SPINLOCK lock;
|
||||
int active; /**< True if the port has not been deleted */
|
||||
struct servlistener* next; /**< Next service protocol */
|
||||
} SERV_LISTENER; // TODO: Rename to LISTENER
|
||||
|
||||
typedef struct listener_iterator
|
||||
{
|
||||
@ -65,7 +66,7 @@ typedef struct listener_iterator
|
||||
* @param listener Listener to serialize
|
||||
* @return True if the serialization of the listener was successful, false if it fails
|
||||
*/
|
||||
bool listener_serialize(const SERV_LISTENER *listener);
|
||||
bool listener_serialize(const SERV_LISTENER* listener);
|
||||
|
||||
/**
|
||||
* @brief Convert listener to JSON
|
||||
@ -76,12 +77,17 @@ bool listener_serialize(const SERV_LISTENER *listener);
|
||||
*/
|
||||
json_t* listener_to_json(const SERV_LISTENER* listener);
|
||||
|
||||
SERV_LISTENER* listener_alloc(struct service* service, const char* name, const char *protocol,
|
||||
const char *address, unsigned short port, const char *authenticator,
|
||||
const char* auth_options, SSL_LISTENER *ssl);
|
||||
SERV_LISTENER* listener_alloc(struct service* service,
|
||||
const char* name,
|
||||
const char* protocol,
|
||||
const char* address,
|
||||
unsigned short port,
|
||||
const char* authenticator,
|
||||
const char* auth_options,
|
||||
SSL_LISTENER* ssl);
|
||||
void listener_free(SERV_LISTENER* listener);
|
||||
int listener_set_ssl_version(SSL_LISTENER *ssl_listener, const char* version);
|
||||
void listener_set_certificates(SSL_LISTENER *ssl_listener, char* cert, char* key, char* ca_cert);
|
||||
int listener_set_ssl_version(SSL_LISTENER* ssl_listener, const char* version);
|
||||
void listener_set_certificates(SSL_LISTENER* ssl_listener, char* cert, char* key, char* ca_cert);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
@ -24,11 +24,11 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#if !defined(MXS_MODULE_NAME)
|
||||
#if !defined (MXS_MODULE_NAME)
|
||||
#define MXS_MODULE_NAME NULL
|
||||
#endif
|
||||
|
||||
#if !defined(MXB_MODULE_NAME)
|
||||
#if !defined (MXB_MODULE_NAME)
|
||||
#define MXB_MODULE_NAME MXS_MODULE_NAME
|
||||
#endif
|
||||
|
||||
@ -50,9 +50,9 @@ typedef MXB_LOG_THROTTLING MXS_LOG_THROTTLING;
|
||||
*/
|
||||
bool mxs_log_init(const char* ident, const char* logdir, mxs_log_target_t target);
|
||||
|
||||
#define mxs_log_finish mxb_log_finish
|
||||
#define mxs_log_message mxb_log_message
|
||||
#define mxs_log_rotate mxb_log_rotate
|
||||
#define mxs_log_finish mxb_log_finish
|
||||
#define mxs_log_message mxb_log_message
|
||||
#define mxs_log_rotate mxb_log_rotate
|
||||
|
||||
#define mxs_log_get_throttling mxb_log_get_throttling
|
||||
#define mxs_log_is_priority_enabled mxb_log_is_priority_enabled
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <mysql.h>
|
||||
@ -95,9 +95,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
SizesAndName(int64_t total,
|
||||
int64_t used,
|
||||
int64_t available,
|
||||
SizesAndName(int64_t total,
|
||||
int64_t used,
|
||||
int64_t available,
|
||||
const std::string& name)
|
||||
: Sizes(total, used, available)
|
||||
, m_name(name)
|
||||
@ -127,9 +127,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
SizesAndPaths(int64_t total,
|
||||
int64_t used,
|
||||
int64_t available,
|
||||
SizesAndPaths(int64_t total,
|
||||
int64_t used,
|
||||
int64_t available,
|
||||
const std::string& path)
|
||||
: Sizes(total, used, available)
|
||||
{
|
||||
@ -190,8 +190,5 @@ int get_info_by_path(MYSQL* pMysql, std::map<std::string, disk::SizesAndName>* p
|
||||
* version is too old or the plugin @c DISKS has not been installed.
|
||||
*/
|
||||
int get_info_by_disk(MYSQL* pMysql, std::map<std::string, disk::SizesAndPaths>* pInfo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -10,26 +10,26 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <maxscale/paths.h>
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define MAXADMIN_DEFAULT_SOCKET MXS_DEFAULT_MAXADMIN_SOCKET
|
||||
#define MAXADMIN_DEFAULT_SOCKET MXS_DEFAULT_MAXADMIN_SOCKET
|
||||
|
||||
#define MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG_LEN 7
|
||||
#define MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG "default"
|
||||
|
||||
#define MAXADMIN_AUTH_REPLY_LEN 6
|
||||
#define MAXADMIN_AUTH_FAILED_REPLY "FAILED"
|
||||
#define MAXADMIN_AUTH_SUCCESS_REPLY "OK----"
|
||||
#define MAXADMIN_AUTH_REPLY_LEN 6
|
||||
#define MAXADMIN_AUTH_FAILED_REPLY "FAILED"
|
||||
#define MAXADMIN_AUTH_SUCCESS_REPLY "OK----"
|
||||
|
||||
#define MAXADMIN_AUTH_USER_PROMPT "USER"
|
||||
#define MAXADMIN_AUTH_USER_PROMPT_LEN 4
|
||||
#define MAXADMIN_AUTH_USER_PROMPT "USER"
|
||||
#define MAXADMIN_AUTH_USER_PROMPT_LEN 4
|
||||
|
||||
#define MAXADMIN_AUTH_PASSWORD_PROMPT "PASSWORD"
|
||||
#define MAXADMIN_AUTH_PASSWORD_PROMPT_LEN 8
|
||||
#define MAXADMIN_AUTH_PASSWORD_PROMPT "PASSWORD"
|
||||
#define MAXADMIN_AUTH_PASSWORD_PROMPT_LEN 8
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,11 +10,11 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/maxscale.h Some general definitions for MaxScale
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file modinfo.h The module information interface
|
||||
@ -67,32 +67,32 @@ typedef enum
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
} MXS_MODULE_VERSION;
|
||||
|
||||
enum mxs_module_param_type
|
||||
{
|
||||
MXS_MODULE_PARAM_COUNT, /**< Non-negative number */
|
||||
MXS_MODULE_PARAM_INT, /**< Integer number */
|
||||
MXS_MODULE_PARAM_SIZE, /**< Size in bytes */
|
||||
MXS_MODULE_PARAM_BOOL, /**< Boolean value */
|
||||
MXS_MODULE_PARAM_STRING, /**< String value */
|
||||
MXS_MODULE_PARAM_QUOTEDSTRING, /**< String enclosed in '"':s */
|
||||
MXS_MODULE_PARAM_ENUM, /**< Enumeration of string values */
|
||||
MXS_MODULE_PARAM_PATH, /**< Path to a file or a directory */
|
||||
MXS_MODULE_PARAM_SERVICE, /**< Service name */
|
||||
MXS_MODULE_PARAM_SERVER, /**< Server name */
|
||||
MXS_MODULE_PARAM_SERVERLIST, /**< List of server names, separated by ',' */
|
||||
MXS_MODULE_PARAM_REGEX /**< A regex string enclosed in '/' */
|
||||
MXS_MODULE_PARAM_COUNT, /**< Non-negative number */
|
||||
MXS_MODULE_PARAM_INT, /**< Integer number */
|
||||
MXS_MODULE_PARAM_SIZE, /**< Size in bytes */
|
||||
MXS_MODULE_PARAM_BOOL, /**< Boolean value */
|
||||
MXS_MODULE_PARAM_STRING, /**< String value */
|
||||
MXS_MODULE_PARAM_QUOTEDSTRING, /**< String enclosed in '"':s */
|
||||
MXS_MODULE_PARAM_ENUM, /**< Enumeration of string values */
|
||||
MXS_MODULE_PARAM_PATH, /**< Path to a file or a directory */
|
||||
MXS_MODULE_PARAM_SERVICE, /**< Service name */
|
||||
MXS_MODULE_PARAM_SERVER, /**< Server name */
|
||||
MXS_MODULE_PARAM_SERVERLIST, /**< List of server names, separated by ',' */
|
||||
MXS_MODULE_PARAM_REGEX /**< A regex string enclosed in '/' */
|
||||
};
|
||||
|
||||
/** Maximum and minimum values for integer types */
|
||||
#define MXS_MODULE_PARAM_COUNT_MAX "2147483647"
|
||||
#define MXS_MODULE_PARAM_COUNT_MIN "0"
|
||||
#define MXS_MODULE_PARAM_INT_MAX "2147483647"
|
||||
#define MXS_MODULE_PARAM_INT_MIN "-2147483647"
|
||||
#define MXS_MODULE_PARAM_INT_MAX "2147483647"
|
||||
#define MXS_MODULE_PARAM_INT_MIN "-2147483647"
|
||||
|
||||
/** Parameter options
|
||||
*
|
||||
@ -101,34 +101,35 @@ enum mxs_module_param_type
|
||||
enum mxs_module_param_options
|
||||
{
|
||||
MXS_MODULE_OPT_NONE = 0,
|
||||
MXS_MODULE_OPT_REQUIRED = (1 << 0), /**< A required parameter */
|
||||
MXS_MODULE_OPT_PATH_X_OK = (1 << 1), /**< PATH: Execute permission to path required */
|
||||
MXS_MODULE_OPT_PATH_R_OK = (1 << 2), /**< PATH: Read permission to path required */
|
||||
MXS_MODULE_OPT_PATH_W_OK = (1 << 3), /**< PATH: Write permission to path required */
|
||||
MXS_MODULE_OPT_PATH_F_OK = (1 << 4), /**< PATH: Path must exist */
|
||||
MXS_MODULE_OPT_PATH_CREAT = (1 << 5), /**< PATH: Create path if it doesn't exist */
|
||||
MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6), /**< ENUM: Only one value can be defined */
|
||||
MXS_MODULE_OPT_REQUIRED = (1 << 0), /**< A required parameter */
|
||||
MXS_MODULE_OPT_PATH_X_OK = (1 << 1), /**< PATH: Execute permission to path required */
|
||||
MXS_MODULE_OPT_PATH_R_OK = (1 << 2), /**< PATH: Read permission to path required */
|
||||
MXS_MODULE_OPT_PATH_W_OK = (1 << 3), /**< PATH: Write permission to path required */
|
||||
MXS_MODULE_OPT_PATH_F_OK = (1 << 4), /**< PATH: Path must exist */
|
||||
MXS_MODULE_OPT_PATH_CREAT = (1 << 5), /**< PATH: Create path if it doesn't exist */
|
||||
MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6), /**< ENUM: Only one value can be defined */
|
||||
|
||||
/**< Parameter is deprecated: Causes a warning to be logged if the parameter
|
||||
* is used but will not cause a configuration error. */
|
||||
MXS_MODULE_OPT_DEPRECATED = (1 << 7),
|
||||
MXS_MODULE_OPT_DEPRECATED = (1 << 7),
|
||||
};
|
||||
|
||||
/** String to enum value mappings */
|
||||
typedef struct mxs_enum_value
|
||||
{
|
||||
const char *name; /**< Name of the enum value */
|
||||
const char* name; /**< Name of the enum value */
|
||||
uint64_t enum_value; /**< The integer value of the enum */
|
||||
} MXS_ENUM_VALUE;
|
||||
|
||||
/** Module parameter declaration */
|
||||
typedef struct mxs_module_param
|
||||
{
|
||||
const char *name; /**< Name of the parameter */
|
||||
enum mxs_module_param_type type; /**< Type of the parameter */
|
||||
const char *default_value; /**< Default value for the parameter, NULL for no default value */
|
||||
uint64_t options; /**< Parameter options */
|
||||
const MXS_ENUM_VALUE *accepted_values; /**< Only for enum values */
|
||||
const char* name; /**< Name of the parameter */
|
||||
enum mxs_module_param_type type; /**< Type of the parameter */
|
||||
const char* default_value; /**< Default value for the parameter, NULL for no default
|
||||
* value */
|
||||
uint64_t options; /**< Parameter options */
|
||||
const MXS_ENUM_VALUE* accepted_values; /**< Only for enum values */
|
||||
} MXS_MODULE_PARAM;
|
||||
|
||||
/** Maximum number of parameters that modules can declare */
|
||||
@ -139,26 +140,26 @@ typedef struct mxs_module_param
|
||||
*/
|
||||
typedef struct mxs_module
|
||||
{
|
||||
MXS_MODULE_API modapi; /**< Module API type */
|
||||
MXS_MODULE_STATUS status; /**< Module development status */
|
||||
MXS_MODULE_VERSION api_version; /**< Module API version */
|
||||
const char *description; /**< Module description */
|
||||
const char *version; /**< Module version */
|
||||
uint64_t module_capabilities; /**< Declared module capabilities */
|
||||
void *module_object; /**< Module type specific API implementation */
|
||||
MXS_MODULE_API modapi; /**< Module API type */
|
||||
MXS_MODULE_STATUS status; /**< Module development status */
|
||||
MXS_MODULE_VERSION api_version; /**< Module API version */
|
||||
const char* description; /**< Module description */
|
||||
const char* version; /**< Module version */
|
||||
uint64_t module_capabilities; /**< Declared module capabilities */
|
||||
void* module_object; /**< Module type specific API implementation */
|
||||
/**
|
||||
* If non-NULL, this function is called once at process startup. If the
|
||||
* function fails, MariaDB MaxScale will not start.
|
||||
*
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int (*process_init)();
|
||||
int (* process_init)();
|
||||
|
||||
/**
|
||||
* If non-NULL, this function is called once at process shutdown, provided
|
||||
* the call to @c init succeeded.
|
||||
*/
|
||||
void (*process_finish)();
|
||||
void (* process_finish)();
|
||||
|
||||
/**
|
||||
* If non-NULL, this function is called once at the startup of every new thread.
|
||||
@ -168,7 +169,7 @@ typedef struct mxs_module
|
||||
*
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int (*thread_init)();
|
||||
int (* thread_init)();
|
||||
|
||||
/**
|
||||
* If non-NULL, this function is called when a thread terminates, provided the
|
||||
@ -176,9 +177,9 @@ typedef struct mxs_module
|
||||
*
|
||||
* @attention This function is *not* called for the thread where @c init is called.
|
||||
*/
|
||||
void (*thread_finish)();
|
||||
void (* thread_finish)();
|
||||
|
||||
MXS_MODULE_PARAM parameters[MXS_MODULE_PARAM_MAX + 1]; /**< Declared parameters */
|
||||
MXS_MODULE_PARAM parameters[MXS_MODULE_PARAM_MAX + 1]; /**< Declared parameters */
|
||||
} MXS_MODULE;
|
||||
|
||||
/**
|
||||
@ -231,28 +232,40 @@ static inline const char* mxs_module_param_type_to_string(enum mxs_module_param_
|
||||
{
|
||||
case MXS_MODULE_PARAM_COUNT:
|
||||
return "count";
|
||||
|
||||
case MXS_MODULE_PARAM_INT:
|
||||
return "int";
|
||||
|
||||
case MXS_MODULE_PARAM_SIZE:
|
||||
return "size";
|
||||
|
||||
case MXS_MODULE_PARAM_BOOL:
|
||||
return "bool";
|
||||
|
||||
case MXS_MODULE_PARAM_STRING:
|
||||
return "string";
|
||||
|
||||
case MXS_MODULE_PARAM_QUOTEDSTRING:
|
||||
return "quoted string";
|
||||
|
||||
case MXS_MODULE_PARAM_ENUM:
|
||||
return "enum";
|
||||
|
||||
case MXS_MODULE_PARAM_PATH:
|
||||
return "path";
|
||||
|
||||
case MXS_MODULE_PARAM_SERVICE:
|
||||
return "service";
|
||||
|
||||
case MXS_MODULE_PARAM_SERVER:
|
||||
return "server";
|
||||
|
||||
case MXS_MODULE_PARAM_SERVERLIST:
|
||||
return "serverlist";
|
||||
|
||||
case MXS_MODULE_PARAM_REGEX:
|
||||
return "regular expression";
|
||||
|
||||
default:
|
||||
mxb_assert(!true);
|
||||
return "unknown";
|
||||
@ -265,16 +278,22 @@ static inline const char* mxs_module_api_to_string(MXS_MODULE_API type)
|
||||
{
|
||||
case MXS_MODULE_API_PROTOCOL:
|
||||
return "protocol";
|
||||
|
||||
case MXS_MODULE_API_ROUTER:
|
||||
return "router";
|
||||
|
||||
case MXS_MODULE_API_MONITOR:
|
||||
return "monitor";
|
||||
|
||||
case MXS_MODULE_API_FILTER:
|
||||
return "filter";
|
||||
|
||||
case MXS_MODULE_API_AUTHENTICATOR:
|
||||
return "authenticator";
|
||||
|
||||
case MXS_MODULE_API_QUERY_CLASSIFIER:
|
||||
return "query_classifier";
|
||||
|
||||
default:
|
||||
mxb_assert(!true);
|
||||
return "unknown";
|
||||
@ -287,14 +306,19 @@ static inline const char* mxs_module_status_to_string(MXS_MODULE_STATUS type)
|
||||
{
|
||||
case MXS_MODULE_IN_DEVELOPMENT:
|
||||
return "In development";
|
||||
|
||||
case MXS_MODULE_ALPHA_RELEASE:
|
||||
return "Alpha";
|
||||
|
||||
case MXS_MODULE_BETA_RELEASE:
|
||||
return "Beta";
|
||||
|
||||
case MXS_MODULE_GA:
|
||||
return "GA";
|
||||
|
||||
case MXS_MODULE_EXPERIMENTAL:
|
||||
return "Experimental";
|
||||
|
||||
default:
|
||||
mxb_assert(!true);
|
||||
return "Unknown";
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file module_command.h Module driven commands
|
||||
@ -44,8 +44,8 @@ MXS_BEGIN_DECLS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t type; /**< The argument type and options */
|
||||
const char *description; /**< The argument description */
|
||||
uint64_t type; /**< The argument type and options */
|
||||
const char* description;/**< The argument description */
|
||||
} modulecmd_arg_type_t;
|
||||
|
||||
/**
|
||||
@ -53,15 +53,15 @@ typedef struct
|
||||
* the modulecmd_arg_type_t type's @c value member. An argument can be of
|
||||
* only one type.
|
||||
*/
|
||||
#define MODULECMD_ARG_NONE 0 /**< Empty argument */
|
||||
#define MODULECMD_ARG_STRING 1 /**< String */
|
||||
#define MODULECMD_ARG_BOOLEAN 2 /**< Boolean value */
|
||||
#define MODULECMD_ARG_SERVICE 3 /**< Service */
|
||||
#define MODULECMD_ARG_SERVER 4 /**< Server */
|
||||
#define MODULECMD_ARG_SESSION 6 /**< Session */
|
||||
#define MODULECMD_ARG_DCB 8 /**< DCB */
|
||||
#define MODULECMD_ARG_MONITOR 9 /**< Monitor */
|
||||
#define MODULECMD_ARG_FILTER 10 /**< Filter */
|
||||
#define MODULECMD_ARG_NONE 0 /**< Empty argument */
|
||||
#define MODULECMD_ARG_STRING 1 /**< String */
|
||||
#define MODULECMD_ARG_BOOLEAN 2 /**< Boolean value */
|
||||
#define MODULECMD_ARG_SERVICE 3 /**< Service */
|
||||
#define MODULECMD_ARG_SERVER 4 /**< Server */
|
||||
#define MODULECMD_ARG_SESSION 6 /**< Session */
|
||||
#define MODULECMD_ARG_DCB 8 /**< DCB */
|
||||
#define MODULECMD_ARG_MONITOR 9 /**< Monitor */
|
||||
#define MODULECMD_ARG_FILTER 10 /**< Filter */
|
||||
|
||||
/** What type of an action does the command perform? */
|
||||
enum modulecmd_type
|
||||
@ -73,31 +73,31 @@ enum modulecmd_type
|
||||
/**
|
||||
* Options for arguments, bits 9 through 32
|
||||
*/
|
||||
#define MODULECMD_ARG_OPTIONAL (1 << 8) /**< The argument is optional */
|
||||
#define MODULECMD_ARG_NAME_MATCHES_DOMAIN (1 << 9) /**< Argument module name must match domain name */
|
||||
#define MODULECMD_ARG_OPTIONAL (1 << 8) /**< The argument is optional */
|
||||
#define MODULECMD_ARG_NAME_MATCHES_DOMAIN (1 << 9) /**< Argument module name must match domain name */
|
||||
|
||||
/**
|
||||
* Helper macros
|
||||
*/
|
||||
#define MODULECMD_GET_TYPE(t) ((t)->type & 0xff)
|
||||
#define MODULECMD_ARG_IS_REQUIRED(t) (((t)->type & MODULECMD_ARG_OPTIONAL) == 0)
|
||||
#define MODULECMD_GET_TYPE(t) ((t)->type & 0xff)
|
||||
#define MODULECMD_ARG_IS_REQUIRED(t) (((t)->type & MODULECMD_ARG_OPTIONAL) == 0)
|
||||
#define MODULECMD_ALLOW_NAME_MISMATCH(t) (((t)->type & MODULECMD_ARG_NAME_MATCHES_DOMAIN) == 0)
|
||||
#define MODULECMD_ARG_PRESENT(t) (MODULECMD_GET_TYPE(t) != MODULECMD_ARG_NONE)
|
||||
#define MODULECMD_ARG_PRESENT(t) (MODULECMD_GET_TYPE(t) != MODULECMD_ARG_NONE)
|
||||
|
||||
/** Argument list node */
|
||||
struct arg_node
|
||||
{
|
||||
modulecmd_arg_type_t type;
|
||||
modulecmd_arg_type_t type;
|
||||
union
|
||||
{
|
||||
char *string;
|
||||
bool boolean;
|
||||
SERVICE *service;
|
||||
SERVER *server;
|
||||
MXS_SESSION *session;
|
||||
DCB *dcb;
|
||||
MXS_MONITOR *monitor;
|
||||
MXS_FILTER_DEF *filter;
|
||||
char* string;
|
||||
bool boolean;
|
||||
SERVICE* service;
|
||||
SERVER* server;
|
||||
MXS_SESSION* session;
|
||||
DCB* dcb;
|
||||
MXS_MONITOR* monitor;
|
||||
MXS_FILTER_DEF* filter;
|
||||
} value;
|
||||
};
|
||||
|
||||
@ -105,7 +105,7 @@ struct arg_node
|
||||
typedef struct
|
||||
{
|
||||
int argc;
|
||||
struct arg_node *argv;
|
||||
struct arg_node* argv;
|
||||
} MODULECMD_ARG;
|
||||
|
||||
/**
|
||||
@ -129,22 +129,22 @@ typedef struct
|
||||
*
|
||||
* @return True on success, false on error
|
||||
*/
|
||||
typedef bool (*MODULECMDFN)(const MODULECMD_ARG *argv, json_t** output);
|
||||
typedef bool (* MODULECMDFN)(const MODULECMD_ARG* argv, json_t** output);
|
||||
|
||||
/**
|
||||
* A registered command
|
||||
*/
|
||||
typedef struct modulecmd
|
||||
{
|
||||
char *identifier; /**< Unique identifier */
|
||||
char *domain; /**< Command domain */
|
||||
char *description; /**< Command description */
|
||||
enum modulecmd_type type; /**< Command type, either active or passive */
|
||||
MODULECMDFN func; /**< The registered function */
|
||||
int arg_count_min; /**< Minimum number of arguments */
|
||||
int arg_count_max; /**< Maximum number of arguments */
|
||||
modulecmd_arg_type_t *arg_types; /**< Argument types */
|
||||
struct modulecmd *next; /**< Next command */
|
||||
char* identifier; /**< Unique identifier */
|
||||
char* domain; /**< Command domain */
|
||||
char* description; /**< Command description */
|
||||
enum modulecmd_type type; /**< Command type, either active or passive */
|
||||
MODULECMDFN func; /**< The registered function */
|
||||
int arg_count_min;/**< Minimum number of arguments */
|
||||
int arg_count_max;/**< Maximum number of arguments */
|
||||
modulecmd_arg_type_t* arg_types; /**< Argument types */
|
||||
struct modulecmd* next; /**< Next command */
|
||||
} MODULECMD;
|
||||
|
||||
/** Check if the module command can modify the data/state of the module */
|
||||
@ -164,10 +164,13 @@ typedef struct modulecmd
|
||||
*
|
||||
* @return True if the module was successfully registered, false on error
|
||||
*/
|
||||
bool modulecmd_register_command(const char *domain, const char *identifier,
|
||||
enum modulecmd_type type, MODULECMDFN entry_point,
|
||||
int argc, modulecmd_arg_type_t *argv,
|
||||
const char *description);
|
||||
bool modulecmd_register_command(const char* domain,
|
||||
const char* identifier,
|
||||
enum modulecmd_type type,
|
||||
MODULECMDFN entry_point,
|
||||
int argc,
|
||||
modulecmd_arg_type_t* argv,
|
||||
const char* description);
|
||||
|
||||
/**
|
||||
* @brief Find a registered command
|
||||
@ -176,7 +179,7 @@ bool modulecmd_register_command(const char *domain, const char *identifier,
|
||||
* @param identifier Command identifier
|
||||
* @return Registered command or NULL if no command was found
|
||||
*/
|
||||
const MODULECMD* modulecmd_find_command(const char *domain, const char *identifier);
|
||||
const MODULECMD* modulecmd_find_command(const char* domain, const char* identifier);
|
||||
|
||||
/**
|
||||
* @brief Parse arguments for a command
|
||||
@ -199,13 +202,13 @@ const MODULECMD* modulecmd_find_command(const char *domain, const char *identifi
|
||||
* @param argv Argument list in string format of size @c argc
|
||||
* @return Parsed arguments or NULL on error
|
||||
*/
|
||||
MODULECMD_ARG* modulecmd_arg_parse(const MODULECMD *cmd, int argc, const void **argv);
|
||||
MODULECMD_ARG* modulecmd_arg_parse(const MODULECMD* cmd, int argc, const void** argv);
|
||||
|
||||
/**
|
||||
* @brief Free parsed arguments returned by modulecmd_arg_parse
|
||||
* @param arg Arguments to free
|
||||
*/
|
||||
void modulecmd_arg_free(MODULECMD_ARG *arg);
|
||||
void modulecmd_arg_free(MODULECMD_ARG* arg);
|
||||
|
||||
/**
|
||||
* @brief Check if an optional argument was defined
|
||||
@ -217,7 +220,7 @@ void modulecmd_arg_free(MODULECMD_ARG *arg);
|
||||
* @param idx Index of the argument, starts at 0
|
||||
* @return True if the optional argument is present
|
||||
*/
|
||||
bool modulecmd_arg_is_present(const MODULECMD_ARG *arg, int idx);
|
||||
bool modulecmd_arg_is_present(const MODULECMD_ARG* arg, int idx);
|
||||
|
||||
/**
|
||||
* @brief Call a registered command
|
||||
@ -232,7 +235,7 @@ bool modulecmd_arg_is_present(const MODULECMD_ARG *arg, int idx);
|
||||
*
|
||||
* @return True on success, false on error
|
||||
*/
|
||||
bool modulecmd_call_command(const MODULECMD *cmd, const MODULECMD_ARG *args, json_t** output);
|
||||
bool modulecmd_call_command(const MODULECMD* cmd, const MODULECMD_ARG* args, json_t** output);
|
||||
|
||||
/**
|
||||
* @brief Set the current error message
|
||||
@ -243,7 +246,7 @@ bool modulecmd_call_command(const MODULECMD *cmd, const MODULECMD_ARG *args, jso
|
||||
* @param format Format string
|
||||
* @param ... Format string arguments
|
||||
*/
|
||||
void modulecmd_set_error(const char *format, ...) mxs_attribute((format (printf, 1, 2)));
|
||||
void modulecmd_set_error(const char* format, ...) mxs_attribute((format (printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* @brief Get the latest error generated by the modulecmd system
|
||||
@ -282,8 +285,10 @@ json_t* modulecmd_get_json_error();
|
||||
* @return True on success, false on PCRE2 error. Use modulecmd_get_error()
|
||||
* to retrieve the error.
|
||||
*/
|
||||
bool modulecmd_foreach(const char *domain_re, const char *ident_re,
|
||||
bool(*fn)(const MODULECMD *cmd, void *data), void *data);
|
||||
bool modulecmd_foreach(const char* domain_re,
|
||||
const char* ident_re,
|
||||
bool (* fn)(const MODULECMD* cmd, void* data),
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief Return argument type as string
|
||||
@ -294,6 +299,6 @@ bool modulecmd_foreach(const char *domain_re, const char *ident_re,
|
||||
* @param type Type to convert
|
||||
* @return New string or NULL on memory allocation error
|
||||
*/
|
||||
const char* modulecmd_argtype_to_str(modulecmd_arg_type_t *type);
|
||||
const char* modulecmd_argtype_to_str(modulecmd_arg_type_t* type);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file modutil.h A set of useful routines for module writers
|
||||
@ -24,34 +24,34 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define PTR_IS_RESULTSET(b) (b[0] == 0x01 && b[1] == 0x0 && b[2] == 0x0 && b[3] == 0x01)
|
||||
#define PTR_IS_EOF(b) (b[0] == 0x05 && b[1] == 0x0 && b[2] == 0x0 && b[4] == 0xfe)
|
||||
#define PTR_IS_OK(b) (b[4] == 0x00)
|
||||
#define PTR_IS_ERR(b) (b[4] == 0xff)
|
||||
#define PTR_IS_RESULTSET(b) (b[0] == 0x01 && b[1] == 0x0 && b[2] == 0x0 && b[3] == 0x01)
|
||||
#define PTR_IS_EOF(b) (b[0] == 0x05 && b[1] == 0x0 && b[2] == 0x0 && b[4] == 0xfe)
|
||||
#define PTR_IS_OK(b) (b[4] == 0x00)
|
||||
#define PTR_IS_ERR(b) (b[4] == 0xff)
|
||||
#define PTR_IS_LOCAL_INFILE(b) (b[4] == 0xfb)
|
||||
#define IS_FULL_RESPONSE(buf) (modutil_count_signal_packets(buf,0,0) == 2)
|
||||
#define IS_FULL_RESPONSE(buf) (modutil_count_signal_packets(buf, 0, 0) == 2)
|
||||
|
||||
extern int modutil_is_SQL(GWBUF *);
|
||||
extern int modutil_is_SQL_prepare(GWBUF *);
|
||||
extern int modutil_extract_SQL(GWBUF *, char **, int *);
|
||||
extern int modutil_MySQL_Query(GWBUF *, char **, int *, int *);
|
||||
extern char* modutil_get_SQL(GWBUF *);
|
||||
extern GWBUF* modutil_replace_SQL(GWBUF *, char *);
|
||||
extern char* modutil_get_query(GWBUF* buf);
|
||||
extern int modutil_send_mysql_err_packet(DCB *, int, int, int, const char *, const char *);
|
||||
GWBUF* modutil_get_next_MySQL_packet(GWBUF** p_readbuf);
|
||||
GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf);
|
||||
int modutil_MySQL_query_len(GWBUF* buf, int* nbytes_missing);
|
||||
void modutil_reply_parse_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
void modutil_reply_auth_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
int modutil_count_statements(GWBUF* buffer);
|
||||
int modutil_count_packets(GWBUF* buffer);
|
||||
GWBUF* modutil_create_query(const char* query);
|
||||
GWBUF* modutil_create_mysql_err_msg(int packet_number,
|
||||
int affected_rows,
|
||||
int merrno,
|
||||
const char *statemsg,
|
||||
const char *msg);
|
||||
extern int modutil_is_SQL(GWBUF*);
|
||||
extern int modutil_is_SQL_prepare(GWBUF*);
|
||||
extern int modutil_extract_SQL(GWBUF*, char**, int*);
|
||||
extern int modutil_MySQL_Query(GWBUF*, char**, int*, int*);
|
||||
extern char* modutil_get_SQL(GWBUF*);
|
||||
extern GWBUF* modutil_replace_SQL(GWBUF*, char*);
|
||||
extern char* modutil_get_query(GWBUF* buf);
|
||||
extern int modutil_send_mysql_err_packet(DCB*, int, int, int, const char*, const char*);
|
||||
GWBUF* modutil_get_next_MySQL_packet(GWBUF** p_readbuf);
|
||||
GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf);
|
||||
int modutil_MySQL_query_len(GWBUF* buf, int* nbytes_missing);
|
||||
void modutil_reply_parse_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
void modutil_reply_auth_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
int modutil_count_statements(GWBUF* buffer);
|
||||
int modutil_count_packets(GWBUF* buffer);
|
||||
GWBUF* modutil_create_query(const char* query);
|
||||
GWBUF* modutil_create_mysql_err_msg(int packet_number,
|
||||
int affected_rows,
|
||||
int merrno,
|
||||
const char* statemsg,
|
||||
const char* msg);
|
||||
|
||||
/** Struct used for tracking the state inside the modutil functions */
|
||||
typedef struct
|
||||
@ -82,7 +82,7 @@ typedef struct
|
||||
*
|
||||
* @return Total number of EOF and ERR packets including the ones already found
|
||||
*/
|
||||
int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more, modutil_state* state);
|
||||
int modutil_count_signal_packets(GWBUF* reply, int n_found, bool* more, modutil_state* state);
|
||||
|
||||
mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char* string);
|
||||
|
||||
@ -111,13 +111,13 @@ char* modutil_MySQL_bypass_whitespace(char* sql, size_t len);
|
||||
* @param dcb The backend DCB where the COM_PING is written
|
||||
* @return True if command was successfully sent
|
||||
*/
|
||||
bool modutil_ignorable_ping(DCB *dcb);
|
||||
bool modutil_ignorable_ping(DCB* dcb);
|
||||
|
||||
/** Character and token searching functions */
|
||||
char* strnchr_esc(char* ptr, char c, int len);
|
||||
char* strnchr_esc_mysql(char* ptr, char c, int len);
|
||||
bool is_mysql_statement_end(const char* start, int len);
|
||||
bool is_mysql_sp_end(const char* start, int len);
|
||||
bool is_mysql_statement_end(const char* start, int len);
|
||||
bool is_mysql_sp_end(const char* start, int len);
|
||||
char* modutil_get_canonical(GWBUF* querybuf);
|
||||
|
||||
// TODO: Move modutil out of the core
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file modutil.hh C++ additions/alternatives for modutil.h functions
|
||||
@ -27,5 +27,4 @@ namespace maxscale
|
||||
std::string extract_sql(GWBUF* buffer, size_t len = -1);
|
||||
|
||||
std::string get_canonical(GWBUF* querybuf);
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/monitor.h - The public monitor interface
|
||||
@ -79,7 +79,7 @@ typedef struct mxs_monitor_api
|
||||
* @return Pointer to the monitor specific data. Will be stored
|
||||
* in @c monitor->handle.
|
||||
*/
|
||||
MXS_MONITOR_INSTANCE *(*createInstance)(MXS_MONITOR *monitor);
|
||||
MXS_MONITOR_INSTANCE*(*createInstance)(MXS_MONITOR * monitor);
|
||||
|
||||
/**
|
||||
* @brief Destroy the monitor.
|
||||
@ -90,7 +90,7 @@ typedef struct mxs_monitor_api
|
||||
*
|
||||
* @param monitor The monitor object.
|
||||
*/
|
||||
void (*destroyInstance)(MXS_MONITOR_INSTANCE *monitor);
|
||||
void (* destroyInstance)(MXS_MONITOR_INSTANCE* monitor);
|
||||
|
||||
/**
|
||||
* @brief Start the monitor
|
||||
@ -104,8 +104,8 @@ typedef struct mxs_monitor_api
|
||||
*
|
||||
* @return True, if the monitor could be started, false otherwise.
|
||||
*/
|
||||
bool (*startMonitor)(MXS_MONITOR_INSTANCE *monitor,
|
||||
const MXS_CONFIG_PARAMETER *params);
|
||||
bool (* startMonitor)(MXS_MONITOR_INSTANCE* monitor,
|
||||
const MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
/**
|
||||
* @brief Stop the monitor
|
||||
@ -115,7 +115,7 @@ typedef struct mxs_monitor_api
|
||||
*
|
||||
* @param monitor The monitor object
|
||||
*/
|
||||
void (*stopMonitor)(MXS_MONITOR_INSTANCE *monitor);
|
||||
void (* stopMonitor)(MXS_MONITOR_INSTANCE* monitor);
|
||||
|
||||
/**
|
||||
* @brief Write diagnostic information to a DCB.
|
||||
@ -123,7 +123,7 @@ typedef struct mxs_monitor_api
|
||||
* @param monitor The monitor object.
|
||||
* @param dcb The dcb to write to.
|
||||
*/
|
||||
void (*diagnostics)(const MXS_MONITOR_INSTANCE* monitor, DCB* dcb);
|
||||
void (* diagnostics)(const MXS_MONITOR_INSTANCE* monitor, DCB* dcb);
|
||||
|
||||
/**
|
||||
* @brief Return diagnostic information about the monitor
|
||||
@ -134,7 +134,7 @@ typedef struct mxs_monitor_api
|
||||
*
|
||||
* @see jansson.h
|
||||
*/
|
||||
json_t* (*diagnostics_json)(const MXS_MONITOR_INSTANCE *monitor);
|
||||
json_t* (*diagnostics_json)(const MXS_MONITOR_INSTANCE * monitor);
|
||||
} MXS_MONITOR_API;
|
||||
|
||||
/**
|
||||
@ -153,13 +153,13 @@ typedef struct mxs_monitor_api
|
||||
*/
|
||||
typedef enum monitor_capability
|
||||
{
|
||||
MCAP_TYPE_NONE = 0x0 // TODO: remove once monitor capabilities are defined
|
||||
MCAP_TYPE_NONE = 0x0 // TODO: remove once monitor capabilities are defined
|
||||
} monitor_capability_t;
|
||||
|
||||
/** Monitor's poll frequency */
|
||||
#define MXS_MON_BASE_INTERVAL_MS 100
|
||||
|
||||
#define MXS_MONITOR_DEFAULT_ID 1UL // unsigned long value
|
||||
#define MXS_MONITOR_DEFAULT_ID 1UL // unsigned long value
|
||||
|
||||
#define MAX_MONITOR_USER_LEN 512
|
||||
#define MAX_MONITOR_PASSWORD_LEN 512
|
||||
@ -186,28 +186,28 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
UNDEFINED_EVENT = 0,
|
||||
MASTER_DOWN_EVENT = (1 << 0), /**< master_down */
|
||||
MASTER_UP_EVENT = (1 << 1), /**< master_up */
|
||||
SLAVE_DOWN_EVENT = (1 << 2), /**< slave_down */
|
||||
SLAVE_UP_EVENT = (1 << 3), /**< slave_up */
|
||||
SERVER_DOWN_EVENT = (1 << 4), /**< server_down */
|
||||
SERVER_UP_EVENT = (1 << 5), /**< server_up */
|
||||
SYNCED_DOWN_EVENT = (1 << 6), /**< synced_down */
|
||||
SYNCED_UP_EVENT = (1 << 7), /**< synced_up */
|
||||
DONOR_DOWN_EVENT = (1 << 8), /**< donor_down */
|
||||
DONOR_UP_EVENT = (1 << 9), /**< donor_up */
|
||||
NDB_DOWN_EVENT = (1 << 10), /**< ndb_down */
|
||||
NDB_UP_EVENT = (1 << 11), /**< ndb_up */
|
||||
LOST_MASTER_EVENT = (1 << 12), /**< lost_master */
|
||||
LOST_SLAVE_EVENT = (1 << 13), /**< lost_slave */
|
||||
LOST_SYNCED_EVENT = (1 << 14), /**< lost_synced */
|
||||
LOST_DONOR_EVENT = (1 << 15), /**< lost_donor */
|
||||
LOST_NDB_EVENT = (1 << 16), /**< lost_ndb */
|
||||
NEW_MASTER_EVENT = (1 << 17), /**< new_master */
|
||||
NEW_SLAVE_EVENT = (1 << 18), /**< new_slave */
|
||||
NEW_SYNCED_EVENT = (1 << 19), /**< new_synced */
|
||||
NEW_DONOR_EVENT = (1 << 20), /**< new_donor */
|
||||
NEW_NDB_EVENT = (1 << 21), /**< new_ndb */
|
||||
MASTER_DOWN_EVENT = (1 << 0), /**< master_down */
|
||||
MASTER_UP_EVENT = (1 << 1), /**< master_up */
|
||||
SLAVE_DOWN_EVENT = (1 << 2), /**< slave_down */
|
||||
SLAVE_UP_EVENT = (1 << 3), /**< slave_up */
|
||||
SERVER_DOWN_EVENT = (1 << 4), /**< server_down */
|
||||
SERVER_UP_EVENT = (1 << 5), /**< server_up */
|
||||
SYNCED_DOWN_EVENT = (1 << 6), /**< synced_down */
|
||||
SYNCED_UP_EVENT = (1 << 7), /**< synced_up */
|
||||
DONOR_DOWN_EVENT = (1 << 8), /**< donor_down */
|
||||
DONOR_UP_EVENT = (1 << 9), /**< donor_up */
|
||||
NDB_DOWN_EVENT = (1 << 10), /**< ndb_down */
|
||||
NDB_UP_EVENT = (1 << 11), /**< ndb_up */
|
||||
LOST_MASTER_EVENT = (1 << 12), /**< lost_master */
|
||||
LOST_SLAVE_EVENT = (1 << 13), /**< lost_slave */
|
||||
LOST_SYNCED_EVENT = (1 << 14), /**< lost_synced */
|
||||
LOST_DONOR_EVENT = (1 << 15), /**< lost_donor */
|
||||
LOST_NDB_EVENT = (1 << 16), /**< lost_ndb */
|
||||
NEW_MASTER_EVENT = (1 << 17), /**< new_master */
|
||||
NEW_SLAVE_EVENT = (1 << 18), /**< new_slave */
|
||||
NEW_SYNCED_EVENT = (1 << 19), /**< new_synced */
|
||||
NEW_DONOR_EVENT = (1 << 20), /**< new_donor */
|
||||
NEW_NDB_EVENT = (1 << 21), /**< new_ndb */
|
||||
} mxs_monitor_event_t;
|
||||
|
||||
/**
|
||||
@ -215,14 +215,14 @@ typedef enum
|
||||
*/
|
||||
typedef struct monitored_server
|
||||
{
|
||||
SERVER *server; /**< The server being monitored */
|
||||
MYSQL *con; /**< The MySQL connection */
|
||||
bool log_version_err;
|
||||
int mon_err_count;
|
||||
uint64_t mon_prev_status; /**< Status before starting the current monitor loop */
|
||||
uint64_t pending_status; /**< Status during current monitor loop */
|
||||
int64_t disk_space_checked; /**< When was the disk space checked the last time */
|
||||
struct monitored_server *next; /**< The next server in the list */
|
||||
SERVER* server;/**< The server being monitored */
|
||||
MYSQL* con; /**< The MySQL connection */
|
||||
bool log_version_err;
|
||||
int mon_err_count;
|
||||
uint64_t mon_prev_status; /**< Status before starting the current monitor loop */
|
||||
uint64_t pending_status; /**< Status during current monitor loop */
|
||||
int64_t disk_space_checked;/**< When was the disk space checked the last time */
|
||||
struct monitored_server* next; /**< The next server in the list */
|
||||
} MXS_MONITORED_SERVER;
|
||||
|
||||
/**
|
||||
@ -230,39 +230,46 @@ typedef struct monitored_server
|
||||
*/
|
||||
struct mxs_monitor
|
||||
{
|
||||
char *name; /**< The name of the monitor module */
|
||||
char user[MAX_MONITOR_USER_LEN]; /*< Monitor username */
|
||||
char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */
|
||||
SPINLOCK lock;
|
||||
MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */
|
||||
MXS_MONITORED_SERVER* monitored_servers; /*< List of servers the monitor monitors */
|
||||
monitor_state_t state; /**< The state of the monitor. This should ONLY be written to by the admin
|
||||
* thread. */
|
||||
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
|
||||
int connect_attempts; /**< How many times a connection is attempted */
|
||||
int read_timeout; /**< Timeout in seconds to read from the server.
|
||||
* There are retries and the total effective timeout
|
||||
* value is three times the option value.
|
||||
*/
|
||||
int write_timeout; /**< Timeout in seconds for each attempt to write to the server.
|
||||
* There are retries and the total effective timeout value is
|
||||
* two times the option value.
|
||||
*/
|
||||
MXS_MONITOR_API *api; /**< The monitor api */
|
||||
char *module_name; /**< Name of the monitor module */
|
||||
MXS_MONITOR_INSTANCE *instance; /**< Instance returned from startMonitor */
|
||||
size_t interval; /**< The monitor interval */
|
||||
int check_maintenance_flag; /**< Set when admin requests a maintenance status change. */
|
||||
bool active; /**< True if monitor is active */
|
||||
time_t journal_max_age; /**< Maximum age of journal file */
|
||||
uint32_t script_timeout; /**< Timeout in seconds for the monitor scripts */
|
||||
const char* script; /**< Launchable script. */
|
||||
uint64_t events; /**< Enabled monitor events. */
|
||||
uint8_t journal_hash[SHA_DIGEST_LENGTH]; /**< SHA1 hash of the latest written journal */
|
||||
MxsDiskSpaceThreshold* disk_space_threshold; /**< Disk space thresholds */
|
||||
int64_t disk_space_check_interval; /**< How often should a disk space check be made at most. */
|
||||
uint64_t ticks; /**< Number of performed monitoring intervals */
|
||||
struct mxs_monitor *next; /**< Next monitor in the linked list */
|
||||
char* name; /**< The name of the monitor module */
|
||||
char user[MAX_MONITOR_USER_LEN]; /*< Monitor username */
|
||||
char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */
|
||||
SPINLOCK lock;
|
||||
MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */
|
||||
MXS_MONITORED_SERVER* monitored_servers; /*< List of servers the monitor monitors */
|
||||
monitor_state_t state; /**< The state of the monitor. This should ONLY be
|
||||
* written to by the admin
|
||||
* thread. */
|
||||
int connect_timeout; /**< Connect timeout in seconds for
|
||||
* mysql_real_connect */
|
||||
int connect_attempts; /**< How many times a connection is attempted */
|
||||
int read_timeout; /**< Timeout in seconds to read from the server.
|
||||
* There are retries and the total effective
|
||||
*timeout
|
||||
* value is three times the option value.
|
||||
*/
|
||||
int write_timeout; /**< Timeout in seconds for each attempt to write
|
||||
* to the server.
|
||||
* There are retries and the total effective
|
||||
*timeout value is
|
||||
* two times the option value.
|
||||
*/
|
||||
MXS_MONITOR_API* api; /**< The monitor api */
|
||||
char* module_name; /**< Name of the monitor module */
|
||||
MXS_MONITOR_INSTANCE* instance; /**< Instance returned from startMonitor */
|
||||
size_t interval; /**< The monitor interval */
|
||||
int check_maintenance_flag; /**< Set when admin requests a maintenance status
|
||||
* change. */
|
||||
bool active; /**< True if monitor is active */
|
||||
time_t journal_max_age; /**< Maximum age of journal file */
|
||||
uint32_t script_timeout; /**< Timeout in seconds for the monitor scripts */
|
||||
const char* script; /**< Launchable script. */
|
||||
uint64_t events; /**< Enabled monitor events. */
|
||||
uint8_t journal_hash[SHA_DIGEST_LENGTH]; /**< SHA1 hash of the latest written journal */
|
||||
MxsDiskSpaceThreshold* disk_space_threshold; /**< Disk space thresholds */
|
||||
int64_t disk_space_check_interval; /**< How often should a disk space check be made
|
||||
* at most. */
|
||||
uint64_t ticks; /**< Number of performed monitoring intervals */
|
||||
struct mxs_monitor* next; /**< Next monitor in the linked list */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -281,17 +288,17 @@ extern const char CN_SCRIPT_TIMEOUT[];
|
||||
|
||||
bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query);
|
||||
|
||||
void monitor_clear_pending_status(MXS_MONITORED_SERVER *ptr, uint64_t bit);
|
||||
void monitor_set_pending_status(MXS_MONITORED_SERVER *ptr, uint64_t bit);
|
||||
void monitor_check_maintenance_requests(MXS_MONITOR *monitor);
|
||||
void monitor_clear_pending_status(MXS_MONITORED_SERVER* ptr, uint64_t bit);
|
||||
void monitor_set_pending_status(MXS_MONITORED_SERVER* ptr, uint64_t bit);
|
||||
void monitor_check_maintenance_requests(MXS_MONITOR* monitor);
|
||||
|
||||
bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv);
|
||||
bool mon_print_fail_status(MXS_MONITORED_SERVER* mon_srv);
|
||||
|
||||
mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database);
|
||||
bool mon_connection_is_ok(mxs_connect_result_t connect_result);
|
||||
void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval);
|
||||
const char* mon_get_event_name(mxs_monitor_event_t event);
|
||||
mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER* database);
|
||||
bool mon_connection_is_ok(mxs_connect_result_t connect_result);
|
||||
void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval);
|
||||
const char* mon_get_event_name(mxs_monitor_event_t event);
|
||||
|
||||
/**
|
||||
* Alter monitor parameters
|
||||
@ -318,7 +325,7 @@ void mon_alter_parameter(MXS_MONITOR* monitor, const char* key, const char* valu
|
||||
* @param script Script to execute or NULL for no script
|
||||
* @param events Enabled events
|
||||
*/
|
||||
void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events);
|
||||
void mon_process_state_changes(MXS_MONITOR* monitor, const char* script, uint64_t events);
|
||||
|
||||
/**
|
||||
* @brief Hangup connections to failed servers
|
||||
@ -327,7 +334,7 @@ void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_
|
||||
*
|
||||
* @param monitor Monitor object
|
||||
*/
|
||||
void mon_hangup_failed_servers(MXS_MONITOR *monitor);
|
||||
void mon_hangup_failed_servers(MXS_MONITOR* monitor);
|
||||
|
||||
/**
|
||||
* @brief Report query errors
|
||||
@ -371,7 +378,7 @@ json_t* monitor_relations_to_server(const SERVER* server, const char* host);
|
||||
* @param monitor Monitor to journal
|
||||
* @param master The current master server or NULL if no master exists
|
||||
*/
|
||||
void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master);
|
||||
void store_server_journal(MXS_MONITOR* monitor, MXS_MONITORED_SERVER* master);
|
||||
|
||||
/**
|
||||
* @brief Load a journal of server states
|
||||
@ -379,7 +386,7 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master);
|
||||
* @param monitor Monitor where journal is loaded
|
||||
* @param master Set to point to the current master
|
||||
*/
|
||||
void load_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master);
|
||||
void load_server_journal(MXS_MONITOR* monitor, MXS_MONITORED_SERVER** master);
|
||||
|
||||
/**
|
||||
* Find the monitored server representing the server.
|
||||
@ -401,7 +408,9 @@ MXS_MONITORED_SERVER* mon_get_monitored_server(const MXS_MONITOR* mon, SERVER* s
|
||||
* elements. The output must contain NULL before calling this function.
|
||||
* @return Output array size.
|
||||
*/
|
||||
int mon_config_get_servers(const MXS_CONFIG_PARAMETER* params, const char* key, const MXS_MONITOR* mon,
|
||||
int mon_config_get_servers(const MXS_CONFIG_PARAMETER* params,
|
||||
const char* key,
|
||||
const MXS_MONITOR* mon,
|
||||
MXS_MONITORED_SERVER*** monitored_array_out);
|
||||
|
||||
/**
|
||||
@ -412,6 +421,6 @@ int mon_config_get_servers(const MXS_CONFIG_PARAMETER* params, const char* key,
|
||||
*
|
||||
* @return True, if the provided string is valid and the threshold could be set.
|
||||
*/
|
||||
bool monitor_set_disk_space_threshold(MXS_MONITOR *monitor, const char *disk_space_threshold);
|
||||
bool monitor_set_disk_space_threshold(MXS_MONITOR* monitor, const char* disk_space_threshold);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -22,12 +22,12 @@
|
||||
namespace maxscale
|
||||
{
|
||||
|
||||
class MonitorInstance : public MXS_MONITOR_INSTANCE
|
||||
class MonitorInstance : public MXS_MONITOR_INSTANCE
|
||||
, protected maxbase::Worker
|
||||
{
|
||||
public:
|
||||
MonitorInstance(const MonitorInstance&) = delete;
|
||||
MonitorInstance& operator = (const MonitorInstance&) = delete;
|
||||
MonitorInstance& operator=(const MonitorInstance&) = delete;
|
||||
|
||||
virtual ~MonitorInstance();
|
||||
|
||||
@ -204,8 +204,8 @@ protected:
|
||||
*/
|
||||
virtual void process_state_changes();
|
||||
|
||||
MXS_MONITOR* m_monitor; /**< The generic monitor structure. */
|
||||
MXS_MONITORED_SERVER* m_master; /**< Master server */
|
||||
MXS_MONITOR* m_monitor; /**< The generic monitor structure. */
|
||||
MXS_MONITORED_SERVER* m_master; /**< Master server */
|
||||
|
||||
private:
|
||||
std::atomic<bool> m_thread_running; /**< Thread state. Only visible inside MonitorInstance. */
|
||||
@ -225,7 +225,7 @@ class MonitorInstanceSimple : public MonitorInstance
|
||||
{
|
||||
public:
|
||||
MonitorInstanceSimple(const MonitorInstanceSimple&) = delete;
|
||||
MonitorInstanceSimple& operator = (const MonitorInstanceSimple&) = delete;
|
||||
MonitorInstanceSimple& operator=(const MonitorInstanceSimple&) = delete;
|
||||
|
||||
protected:
|
||||
MonitorInstanceSimple(MXS_MONITOR* pMonitor)
|
||||
@ -271,7 +271,7 @@ private:
|
||||
* @c update_server_status() will *not* be called.
|
||||
* - After the call, update the error count of the server if it is down.
|
||||
*/
|
||||
void tick(); // final
|
||||
void tick(); // final
|
||||
};
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ class MonitorApi
|
||||
public:
|
||||
MonitorApi() = delete;
|
||||
MonitorApi(const MonitorApi&) = delete;
|
||||
MonitorApi& operator = (const MonitorApi&) = delete;
|
||||
MonitorApi& operator=(const MonitorApi&) = delete;
|
||||
|
||||
static MXS_MONITOR_INSTANCE* createInstance(MXS_MONITOR* pMonitor)
|
||||
{
|
||||
@ -349,5 +349,4 @@ MXS_MONITOR_API MonitorApi<MonitorInstance>::s_api =
|
||||
* @return The host and port of the monitor or an empty string and 0 if an error occurred
|
||||
*/
|
||||
std::pair<std::string, int> mon_get_external_master(const std::string& name);
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file mysql_binlog.h - Extracting information from binary logs
|
||||
@ -27,44 +27,44 @@ MXS_BEGIN_DECLS
|
||||
#define GTID_MAX_LEN 64
|
||||
|
||||
/** Table map column types */
|
||||
#define TABLE_COL_TYPE_DECIMAL 0x00
|
||||
#define TABLE_COL_TYPE_TINY 0x01
|
||||
#define TABLE_COL_TYPE_SHORT 0x02
|
||||
#define TABLE_COL_TYPE_LONG 0x03
|
||||
#define TABLE_COL_TYPE_FLOAT 0x04
|
||||
#define TABLE_COL_TYPE_DOUBLE 0x05
|
||||
#define TABLE_COL_TYPE_NULL 0x06
|
||||
#define TABLE_COL_TYPE_TIMESTAMP 0x07
|
||||
#define TABLE_COL_TYPE_LONGLONG 0x08
|
||||
#define TABLE_COL_TYPE_INT24 0x09
|
||||
#define TABLE_COL_TYPE_DATE 0x0a
|
||||
#define TABLE_COL_TYPE_TIME 0x0b
|
||||
#define TABLE_COL_TYPE_DATETIME 0x0c
|
||||
#define TABLE_COL_TYPE_YEAR 0x0d
|
||||
#define TABLE_COL_TYPE_NEWDATE 0x0e
|
||||
#define TABLE_COL_TYPE_VARCHAR 0x0f
|
||||
#define TABLE_COL_TYPE_BIT 0x10
|
||||
#define TABLE_COL_TYPE_TIMESTAMP2 0x11
|
||||
#define TABLE_COL_TYPE_DATETIME2 0x12
|
||||
#define TABLE_COL_TYPE_TIME2 0x13
|
||||
#define TABLE_COL_TYPE_NEWDECIMAL 0xf6
|
||||
#define TABLE_COL_TYPE_ENUM 0xf7
|
||||
#define TABLE_COL_TYPE_SET 0xf8
|
||||
#define TABLE_COL_TYPE_TINY_BLOB 0xf9
|
||||
#define TABLE_COL_TYPE_DECIMAL 0x00
|
||||
#define TABLE_COL_TYPE_TINY 0x01
|
||||
#define TABLE_COL_TYPE_SHORT 0x02
|
||||
#define TABLE_COL_TYPE_LONG 0x03
|
||||
#define TABLE_COL_TYPE_FLOAT 0x04
|
||||
#define TABLE_COL_TYPE_DOUBLE 0x05
|
||||
#define TABLE_COL_TYPE_NULL 0x06
|
||||
#define TABLE_COL_TYPE_TIMESTAMP 0x07
|
||||
#define TABLE_COL_TYPE_LONGLONG 0x08
|
||||
#define TABLE_COL_TYPE_INT24 0x09
|
||||
#define TABLE_COL_TYPE_DATE 0x0a
|
||||
#define TABLE_COL_TYPE_TIME 0x0b
|
||||
#define TABLE_COL_TYPE_DATETIME 0x0c
|
||||
#define TABLE_COL_TYPE_YEAR 0x0d
|
||||
#define TABLE_COL_TYPE_NEWDATE 0x0e
|
||||
#define TABLE_COL_TYPE_VARCHAR 0x0f
|
||||
#define TABLE_COL_TYPE_BIT 0x10
|
||||
#define TABLE_COL_TYPE_TIMESTAMP2 0x11
|
||||
#define TABLE_COL_TYPE_DATETIME2 0x12
|
||||
#define TABLE_COL_TYPE_TIME2 0x13
|
||||
#define TABLE_COL_TYPE_NEWDECIMAL 0xf6
|
||||
#define TABLE_COL_TYPE_ENUM 0xf7
|
||||
#define TABLE_COL_TYPE_SET 0xf8
|
||||
#define TABLE_COL_TYPE_TINY_BLOB 0xf9
|
||||
#define TABLE_COL_TYPE_MEDIUM_BLOB 0xfa
|
||||
#define TABLE_COL_TYPE_LONG_BLOB 0xfb
|
||||
#define TABLE_COL_TYPE_BLOB 0xfc
|
||||
#define TABLE_COL_TYPE_VAR_STRING 0xfd
|
||||
#define TABLE_COL_TYPE_STRING 0xfe
|
||||
#define TABLE_COL_TYPE_GEOMETRY 0xff
|
||||
#define TABLE_COL_TYPE_LONG_BLOB 0xfb
|
||||
#define TABLE_COL_TYPE_BLOB 0xfc
|
||||
#define TABLE_COL_TYPE_VAR_STRING 0xfd
|
||||
#define TABLE_COL_TYPE_STRING 0xfe
|
||||
#define TABLE_COL_TYPE_GEOMETRY 0xff
|
||||
|
||||
/**
|
||||
* RBR row event flags
|
||||
*/
|
||||
#define ROW_EVENT_END_STATEMENT 0x0001
|
||||
#define ROW_EVENT_NO_FKCHECK 0x0002
|
||||
#define ROW_EVENT_NO_UKCHECK 0x0004
|
||||
#define ROW_EVENT_HAS_COLUMNS 0x0008
|
||||
#define ROW_EVENT_NO_FKCHECK 0x0002
|
||||
#define ROW_EVENT_NO_UKCHECK 0x0004
|
||||
#define ROW_EVENT_HAS_COLUMNS 0x0008
|
||||
|
||||
/** The table ID used for end of statement row events */
|
||||
#define TABLE_DUMMY_ID 0x00ffffff
|
||||
@ -85,13 +85,17 @@ bool column_is_decimal(uint8_t type);
|
||||
bool fixed_string_is_enum(uint8_t type);
|
||||
|
||||
/** Value unpacking */
|
||||
size_t unpack_temporal_value(uint8_t type, uint8_t *ptr, uint8_t* metadata, int length, struct tm *tm);
|
||||
size_t unpack_enum(uint8_t *ptr, uint8_t *metadata, uint8_t *dest);
|
||||
size_t unpack_numeric_field(uint8_t *ptr, uint8_t type, uint8_t* metadata, uint8_t* val);
|
||||
size_t unpack_bit(uint8_t *ptr, uint8_t *null_mask, uint32_t col_count,
|
||||
uint32_t curr_col_index, uint8_t *metadata, uint64_t *dest);
|
||||
size_t unpack_decimal_field(uint8_t *ptr, uint8_t *metadata, double *val_float);
|
||||
size_t unpack_temporal_value(uint8_t type, uint8_t* ptr, uint8_t* metadata, int length, struct tm* tm);
|
||||
size_t unpack_enum(uint8_t* ptr, uint8_t* metadata, uint8_t* dest);
|
||||
size_t unpack_numeric_field(uint8_t* ptr, uint8_t type, uint8_t* metadata, uint8_t* val);
|
||||
size_t unpack_bit(uint8_t* ptr,
|
||||
uint8_t* null_mask,
|
||||
uint32_t col_count,
|
||||
uint32_t curr_col_index,
|
||||
uint8_t* metadata,
|
||||
uint64_t* dest);
|
||||
size_t unpack_decimal_field(uint8_t* ptr, uint8_t* metadata, double* val_float);
|
||||
|
||||
void format_temporal_value(char *str, size_t size, uint8_t type, struct tm *tm);
|
||||
void format_temporal_value(char* str, size_t size, uint8_t type, struct tm* tm);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <stdlib.h>
|
||||
@ -21,13 +21,13 @@
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
/** Length-encoded integers */
|
||||
size_t mxs_leint_bytes(const uint8_t* ptr);
|
||||
size_t mxs_leint_bytes(const uint8_t* ptr);
|
||||
uint64_t mxs_leint_value(const uint8_t* c);
|
||||
uint64_t mxs_leint_consume(uint8_t ** c);
|
||||
uint64_t mxs_leint_consume(uint8_t** c);
|
||||
|
||||
/** Length-encoded strings */
|
||||
char* mxs_lestr_consume_dup(uint8_t** c);
|
||||
char* mxs_lestr_consume(uint8_t** c, size_t *size);
|
||||
char* mxs_lestr_consume(uint8_t** c, size_t* size);
|
||||
|
||||
/**
|
||||
* Creates a connection to a MySQL database engine. If necessary, initializes SSL.
|
||||
@ -39,7 +39,7 @@ char* mxs_lestr_consume(uint8_t** c, size_t *size);
|
||||
*
|
||||
* @return New connection or NULL on error
|
||||
*/
|
||||
MYSQL* mxs_mysql_real_connect(MYSQL *mysql, SERVER *server, const char *user, const char *passwd);
|
||||
MYSQL* mxs_mysql_real_connect(MYSQL* mysql, SERVER* server, const char* user, const char* passwd);
|
||||
|
||||
/**
|
||||
* Check if the MYSQL error number is a connection error
|
||||
@ -71,7 +71,7 @@ int mxs_mysql_query(MYSQL* conn, const char* query);
|
||||
*
|
||||
* @note The string is modified in place.
|
||||
*/
|
||||
bool mxs_mysql_trim_quotes(char *s);
|
||||
bool mxs_mysql_trim_quotes(char* s);
|
||||
|
||||
/**
|
||||
* Helper function for getting values by field name
|
||||
@ -87,8 +87,8 @@ const char* mxs_mysql_get_value(MYSQL_RES* result, MYSQL_ROW row, const char* ke
|
||||
|
||||
typedef enum mxs_pcre_quote_approach
|
||||
{
|
||||
MXS_PCRE_QUOTE_VERBATIM, /*<! Quote all PCRE characters. */
|
||||
MXS_PCRE_QUOTE_WILDCARD /*<! Quote all PCRE characters, except % that is converted into .*. */
|
||||
MXS_PCRE_QUOTE_VERBATIM, /*<! Quote all PCRE characters. */
|
||||
MXS_PCRE_QUOTE_WILDCARD /*<! Quote all PCRE characters, except % that is converted into .*. */
|
||||
} mxs_pcre_quote_approach_t;
|
||||
|
||||
typedef enum mxs_mysql_name_kind
|
||||
@ -119,8 +119,8 @@ typedef enum mxs_mysql_name_kind
|
||||
*
|
||||
* @return Whether or not the name contains a wildcard.
|
||||
*/
|
||||
mxs_mysql_name_kind_t mxs_mysql_name_to_pcre(char *pcre,
|
||||
const char *mysql,
|
||||
mxs_mysql_name_kind_t mxs_mysql_name_to_pcre(char* pcre,
|
||||
const char* mysql,
|
||||
mxs_pcre_quote_approach_t approach);
|
||||
|
||||
/**
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file pcre2.h - Utility functions for regular expression matching
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#if defined(PCRE2_CODE_UNIT_WIDTH)
|
||||
#if defined (PCRE2_CODE_UNIT_WIDTH)
|
||||
#error PCRE2_CODE_UNIT_WIDTH already defined. Do not define, and include <maxscale/pcre2.h>.
|
||||
#else
|
||||
#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
@ -33,8 +33,8 @@ MXS_BEGIN_DECLS
|
||||
* Print an error message explaining an error code.
|
||||
* @param errorcode value returned by pcre2 functions
|
||||
*/
|
||||
#define MXS_PCRE2_PRINT_ERROR(errorcode)\
|
||||
mxs_pcre2_print_error(errorcode, MXS_MODULE_NAME, __FILE__,__LINE__, __func__)
|
||||
#define MXS_PCRE2_PRINT_ERROR(errorcode) \
|
||||
mxs_pcre2_print_error(errorcode, MXS_MODULE_NAME, __FILE__, __LINE__, __func__)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -43,16 +43,24 @@ typedef enum
|
||||
MXS_PCRE2_ERROR
|
||||
} mxs_pcre2_result_t;
|
||||
|
||||
mxs_pcre2_result_t mxs_pcre2_substitute(pcre2_code *re, const char *subject,
|
||||
const char *replace, char** dest, size_t* size);
|
||||
mxs_pcre2_result_t mxs_pcre2_simple_match(const char* pattern, const char* subject,
|
||||
int options, int* error);
|
||||
mxs_pcre2_result_t mxs_pcre2_substitute(pcre2_code* re,
|
||||
const char* subject,
|
||||
const char* replace,
|
||||
char** dest,
|
||||
size_t* size);
|
||||
mxs_pcre2_result_t mxs_pcre2_simple_match(const char* pattern,
|
||||
const char* subject,
|
||||
int options,
|
||||
int* error);
|
||||
/**
|
||||
* Print an error message explaining an error code. Best used through the macro
|
||||
* MXS_PCRE2_PRINT_ERROR
|
||||
*/
|
||||
void mxs_pcre2_print_error(int errorcode, const char *module_name, const char *filename,
|
||||
int line_num, const char* func_name);
|
||||
void mxs_pcre2_print_error(int errorcode,
|
||||
const char* module_name,
|
||||
const char* filename,
|
||||
int line_num,
|
||||
const char* func_name);
|
||||
|
||||
/**
|
||||
* Check that @c subject is valid. A valid subject matches @c re_match yet does
|
||||
@ -72,8 +80,11 @@ void mxs_pcre2_print_error(int errorcode, const char *module_name, const char *f
|
||||
* @return True, if subject is considered valid. False if subject is not valid or
|
||||
* an error occurred.
|
||||
*/
|
||||
bool mxs_pcre2_check_match_exclude(pcre2_code* re_match, pcre2_code* re_exclude,
|
||||
pcre2_match_data* md, const char* subject,
|
||||
int length, const char* calling_module);
|
||||
bool mxs_pcre2_check_match_exclude(pcre2_code* re_match,
|
||||
pcre2_code* re_exclude,
|
||||
pcre2_match_data* md,
|
||||
const char* subject,
|
||||
int length,
|
||||
const char* calling_module);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxscale/pcre2.h>
|
||||
@ -62,5 +62,4 @@ struct CloserTraits<pcre2_match_data*>
|
||||
pData = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/poll.h - The public poll interface
|
||||
@ -55,7 +55,7 @@ int64_t poll_get_stat(POLL_STAT stat);
|
||||
*
|
||||
* @param dcb DCB to emulate an EPOLLOUT event for
|
||||
*/
|
||||
void poll_fake_hangup_event(DCB *dcb);
|
||||
void poll_fake_hangup_event(DCB* dcb);
|
||||
|
||||
/*
|
||||
* Insert a fake write completion event for a DCB into the polling
|
||||
@ -70,7 +70,7 @@ void poll_fake_hangup_event(DCB *dcb);
|
||||
*
|
||||
* @param dcb DCB to emulate an EPOLLOUT event for
|
||||
*/
|
||||
void poll_fake_write_event(DCB *dcb);
|
||||
void poll_fake_write_event(DCB* dcb);
|
||||
|
||||
/*
|
||||
* Insert a fake read completion event for a DCB into the polling
|
||||
@ -85,7 +85,7 @@ void poll_fake_write_event(DCB *dcb);
|
||||
*
|
||||
* @param dcb DCB to emulate an EPOLLIN event for
|
||||
*/
|
||||
void poll_fake_read_event(DCB *dcb);
|
||||
void poll_fake_read_event(DCB* dcb);
|
||||
|
||||
/**
|
||||
* Add a DCB to the set of descriptors within the polling
|
||||
@ -94,7 +94,7 @@ void poll_fake_read_event(DCB *dcb);
|
||||
* @param dcb The descriptor to add to the poll
|
||||
* @return -1 on error or 0 on success
|
||||
*/
|
||||
int poll_add_dcb(DCB *);
|
||||
int poll_add_dcb(DCB*);
|
||||
|
||||
/**
|
||||
* Remove a descriptor from the set of descriptors within the
|
||||
@ -103,7 +103,7 @@ int poll_add_dcb(DCB *);
|
||||
* @param dcb The descriptor to remove
|
||||
* @return -1 on error or 0 on success; actually always 0
|
||||
*/
|
||||
int poll_remove_dcb(DCB *);
|
||||
int poll_remove_dcb(DCB*);
|
||||
|
||||
/**
|
||||
* Add given GWBUF to DCB's readqueue and add a pending EPOLLIN event for DCB.
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file protocol.h
|
||||
@ -40,7 +40,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @return 1 on success, 0 on error
|
||||
*/
|
||||
int32_t (*read)(struct dcb* dcb);
|
||||
int32_t (* read)(struct dcb* dcb);
|
||||
|
||||
/**
|
||||
* Write data to a network socket
|
||||
@ -50,7 +50,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @return 1 on success, 0 on error
|
||||
*/
|
||||
int32_t (*write)(struct dcb* dcb, GWBUF* buffer);
|
||||
int32_t (* write)(struct dcb* dcb, GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* EPOLLOUT handler, used to write buffered data
|
||||
@ -61,7 +61,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*write_ready)(struct dcb* dcb);
|
||||
int32_t (* write_ready)(struct dcb* dcb);
|
||||
|
||||
/**
|
||||
* EPOLLERR handler
|
||||
@ -72,7 +72,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*error)(struct dcb* dcb);
|
||||
int32_t (* error)(struct dcb* dcb);
|
||||
|
||||
/**
|
||||
* EPOLLHUP and EPOLLRDHUP handler
|
||||
@ -83,7 +83,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*hangup)(struct dcb* dcb);
|
||||
int32_t (* hangup)(struct dcb* dcb);
|
||||
|
||||
/**
|
||||
* Accept a connection, only for client side protocol modules
|
||||
@ -94,7 +94,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*accept)(struct dcb* dcb);
|
||||
int32_t (* accept)(struct dcb* dcb);
|
||||
|
||||
/**
|
||||
* Connect to a server, only for backend side protocol modules
|
||||
@ -105,7 +105,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @return The opened file descriptor or DCBFD_CLOSED on error
|
||||
*/
|
||||
int32_t (*connect)(struct dcb* dcb, struct server* server, struct session* session);
|
||||
int32_t (* connect)(struct dcb* dcb, struct server* server, struct session* session);
|
||||
|
||||
/**
|
||||
* Free protocol data allocated in the connect handler
|
||||
@ -116,7 +116,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*close)(struct dcb* dcb);
|
||||
int32_t (* close)(struct dcb* dcb);
|
||||
|
||||
/**
|
||||
* Listen on a network socket, only for client side protocol modules
|
||||
@ -126,7 +126,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @return 1 on success, 0 on error
|
||||
*/
|
||||
int32_t (*listen)(struct dcb* dcb, char* address);
|
||||
int32_t (* listen)(struct dcb* dcb, char* address);
|
||||
|
||||
/**
|
||||
* Perform user re-authentication
|
||||
@ -140,7 +140,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*auth)(struct dcb* dcb, struct server* server, struct session* session, GWBUF* buffer);
|
||||
int32_t (* auth)(struct dcb* dcb, struct server* server, struct session* session, GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* Returns the name of the default authenticator module for this protocol
|
||||
@ -159,7 +159,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @note Currently the return value is ignored
|
||||
*/
|
||||
int32_t (*connlimit)(struct dcb* dcb, int limit);
|
||||
int32_t (* connlimit)(struct dcb* dcb, int limit);
|
||||
|
||||
/**
|
||||
* Check if the connection has been fully established, used by connection pooling
|
||||
@ -168,7 +168,7 @@ typedef struct mxs_protocol
|
||||
*
|
||||
* @return True if the connection is fully established and can be pooled
|
||||
*/
|
||||
bool (*established)(struct dcb* );
|
||||
bool (* established)(struct dcb*);
|
||||
|
||||
/**
|
||||
* Provide JSON formatted diagnostics about a DCB
|
||||
@ -178,7 +178,6 @@ typedef struct mxs_protocol
|
||||
* @return JSON representation of the DCB
|
||||
*/
|
||||
json_t* (*diagnostics_json)(struct dcb* dcb);
|
||||
|
||||
} MXS_PROTOCOL;
|
||||
|
||||
/**
|
||||
@ -186,7 +185,7 @@ typedef struct mxs_protocol
|
||||
* the MXS_PROTOCOL structure is changed. See the rules defined in modinfo.h
|
||||
* that define how these numbers should change.
|
||||
*/
|
||||
#define MXS_PROTOCOL_VERSION {2, 0, 0}
|
||||
#define MXS_PROTOCOL_VERSION {2, 0, 0}
|
||||
|
||||
/**
|
||||
* Specifies capabilities specific for protocol.
|
||||
@ -198,7 +197,7 @@ typedef struct mxs_protocol
|
||||
*/
|
||||
typedef enum protocol_capability
|
||||
{
|
||||
PCAP_TYPE_NONE = 0x0 // TODO: remove once protocol capabilities are defined
|
||||
PCAP_TYPE_NONE = 0x0 // TODO: remove once protocol capabilities are defined
|
||||
} protocol_capability_t;
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include <maxscale/protocol/mysql.h>
|
||||
|
||||
/** A DCB-like client abstraction which ignores responses */
|
||||
class LocalClient: public MXB_POLL_DATA
|
||||
class LocalClient : public MXB_POLL_DATA
|
||||
{
|
||||
LocalClient(const LocalClient&);
|
||||
LocalClient& operator=(const LocalClient&);
|
||||
@ -61,19 +61,19 @@ private:
|
||||
static LocalClient* create(MYSQL_session* session, MySQLProtocol* proto, const char* ip, uint64_t port);
|
||||
LocalClient(MYSQL_session* session, MySQLProtocol* proto, int fd);
|
||||
static uint32_t poll_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
||||
void process(uint32_t events);
|
||||
GWBUF* read_complete_packet();
|
||||
void drain_queue();
|
||||
void error();
|
||||
void close();
|
||||
void process(uint32_t events);
|
||||
GWBUF* read_complete_packet();
|
||||
void drain_queue();
|
||||
void error();
|
||||
void close();
|
||||
|
||||
/** Client states */
|
||||
enum vc_state
|
||||
{
|
||||
VC_WAITING_HANDSHAKE, // Initial state
|
||||
VC_RESPONSE_SENT, // Handshake received and response sent
|
||||
VC_OK, // Authentication is complete, ready for queries
|
||||
VC_ERROR // Something went wrong
|
||||
VC_WAITING_HANDSHAKE, // Initial state
|
||||
VC_RESPONSE_SENT, // Handshake received and response sent
|
||||
VC_OK, // Authentication is complete, ready for queries
|
||||
VC_ERROR // Something went wrong
|
||||
};
|
||||
|
||||
vc_state m_state;
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
@ -43,10 +43,10 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define MYSQL_HEADER_LEN 4
|
||||
#define MYSQL_CHECKSUM_LEN 4
|
||||
#define MYSQL_EOF_PACKET_LEN 9
|
||||
#define MYSQL_OK_PACKET_MIN_LEN 11
|
||||
#define MYSQL_HEADER_LEN 4
|
||||
#define MYSQL_CHECKSUM_LEN 4
|
||||
#define MYSQL_EOF_PACKET_LEN 9
|
||||
#define MYSQL_OK_PACKET_MIN_LEN 11
|
||||
#define MYSQL_ERR_PACKET_MIN_LEN 9
|
||||
|
||||
/**
|
||||
@ -58,14 +58,14 @@ MXS_BEGIN_DECLS
|
||||
#define MYSQL_CHARSET_OFFSET 12
|
||||
#define MYSQL_CLIENT_CAP_OFFSET 4
|
||||
#define MYSQL_CLIENT_CAP_SIZE 4
|
||||
#define MARIADB_CAP_OFFSET MYSQL_CHARSET_OFFSET + 19
|
||||
#define MARIADB_CAP_OFFSET MYSQL_CHARSET_OFFSET + 19
|
||||
|
||||
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
|
||||
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
|
||||
#define GW_MYSQL_HANDSHAKE_FILLER 0x00
|
||||
#define GW_MYSQL_SERVER_LANGUAGE 0x08
|
||||
#define GW_MYSQL_MAX_PACKET_LEN 0xffffffL
|
||||
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
||||
#define GW_SCRAMBLE_LENGTH_323 8
|
||||
#define GW_MYSQL_SERVER_LANGUAGE 0x08
|
||||
#define GW_MYSQL_MAX_PACKET_LEN 0xffffffL
|
||||
#define GW_MYSQL_SCRAMBLE_SIZE 20
|
||||
#define GW_SCRAMBLE_LENGTH_323 8
|
||||
|
||||
/**
|
||||
* Prepared statement payload response offsets for a COM_STMT_PREPARE response:
|
||||
@ -106,23 +106,23 @@ MXS_BEGIN_DECLS
|
||||
#define MYSQL_DATABASE_MAXLEN 128
|
||||
#define MYSQL_TABLE_MAXLEN 64
|
||||
|
||||
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
|
||||
#define COM_QUIT_PACKET_SIZE (4+1)
|
||||
#define GW_NOINTR_CALL(A) do {errno = 0; A;} while (errno == EINTR)
|
||||
#define COM_QUIT_PACKET_SIZE (4 + 1)
|
||||
struct dcb;
|
||||
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
TX_EMPTY = 0, ///< "none of the below"
|
||||
TX_EXPLICIT = 1, ///< an explicit transaction is active
|
||||
TX_IMPLICIT = 2, ///< an implicit transaction is active
|
||||
TX_READ_TRX = 4, ///< transactional reads were done
|
||||
TX_READ_UNSAFE = 8, ///< non-transaction reads were done
|
||||
TX_WRITE_TRX = 16, ///< transactional writes were done
|
||||
TX_WRITE_UNSAFE = 32, ///< non-transactional writes were done
|
||||
TX_STMT_UNSAFE = 64, ///< "unsafe" (non-deterministic like UUID()) stmts
|
||||
TX_RESULT_SET = 128, ///< result-set was sent
|
||||
TX_WITH_SNAPSHOT= 256, ///< WITH CONSISTENT SNAPSHOT was used
|
||||
TX_LOCKED_TABLES= 512 ///< LOCK TABLES is active
|
||||
TX_EMPTY = 0, ///< "none of the below"
|
||||
TX_EXPLICIT = 1, ///< an explicit transaction is active
|
||||
TX_IMPLICIT = 2, ///< an implicit transaction is active
|
||||
TX_READ_TRX = 4, ///< transactional reads were done
|
||||
TX_READ_UNSAFE = 8, ///< non-transaction reads were done
|
||||
TX_WRITE_TRX = 16, ///< transactional writes were done
|
||||
TX_WRITE_UNSAFE = 32, ///< non-transactional writes were done
|
||||
TX_STMT_UNSAFE = 64, ///< "unsafe" (non-deterministic like UUID()) stmts
|
||||
TX_RESULT_SET = 128, ///< result-set was sent
|
||||
TX_WITH_SNAPSHOT = 256, ///< WITH CONSISTENT SNAPSHOT was used
|
||||
TX_LOCKED_TABLES = 512 ///< LOCK TABLES is active
|
||||
} mysql_tx_state_t;
|
||||
|
||||
typedef enum
|
||||
@ -139,114 +139,117 @@ typedef enum
|
||||
*/
|
||||
typedef struct mysql_session
|
||||
{
|
||||
uint8_t client_sha1[MYSQL_SCRAMBLE_LEN]; /*< SHA1(password) */
|
||||
char user[MYSQL_USER_MAXLEN + 1]; /*< username */
|
||||
char db[MYSQL_DATABASE_MAXLEN + 1]; /*< database */
|
||||
int auth_token_len; /*< token length */
|
||||
uint8_t *auth_token; /*< token */
|
||||
uint8_t client_sha1[MYSQL_SCRAMBLE_LEN]; /*< SHA1(password) */
|
||||
char user[MYSQL_USER_MAXLEN + 1]; /*< username */
|
||||
char db[MYSQL_DATABASE_MAXLEN + 1]; /*< database */
|
||||
int auth_token_len; /*< token length */
|
||||
uint8_t* auth_token; /*< token */
|
||||
} MYSQL_session;
|
||||
|
||||
/** Protocol packing macros. */
|
||||
#define gw_mysql_set_byte2(__buffer, __int) do { \
|
||||
(__buffer)[0]= (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0)
|
||||
#define gw_mysql_set_byte3(__buffer, __int) do { \
|
||||
(__buffer)[0]= (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0)
|
||||
#define gw_mysql_set_byte4(__buffer, __int) do { \
|
||||
(__buffer)[0]= (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
|
||||
(__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0)
|
||||
#define gw_mysql_set_byte2(__buffer, __int) \
|
||||
do { \
|
||||
(__buffer)[0] = (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1] = (uint8_t)(((__int) >> 8) & 0xFF);} while (0)
|
||||
#define gw_mysql_set_byte3(__buffer, __int) \
|
||||
do { \
|
||||
(__buffer)[0] = (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1] = (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2] = (uint8_t)(((__int) >> 16) & 0xFF);} while (0)
|
||||
#define gw_mysql_set_byte4(__buffer, __int) \
|
||||
do { \
|
||||
(__buffer)[0] = (uint8_t)((__int) & 0xFF); \
|
||||
(__buffer)[1] = (uint8_t)(((__int) >> 8) & 0xFF); \
|
||||
(__buffer)[2] = (uint8_t)(((__int) >> 16) & 0xFF); \
|
||||
(__buffer)[3] = (uint8_t)(((__int) >> 24) & 0xFF);} while (0)
|
||||
|
||||
/** Protocol unpacking macros. */
|
||||
#define gw_mysql_get_byte2(__buffer) \
|
||||
(uint16_t)((__buffer)[0] | \
|
||||
((__buffer)[1] << 8))
|
||||
(uint16_t)((__buffer)[0] \
|
||||
| ((__buffer)[1] << 8))
|
||||
#define gw_mysql_get_byte3(__buffer) \
|
||||
(uint32_t)((__buffer)[0] | \
|
||||
((__buffer)[1] << 8) | \
|
||||
((__buffer)[2] << 16))
|
||||
(uint32_t)((__buffer)[0] \
|
||||
| ((__buffer)[1] << 8) \
|
||||
| ((__buffer)[2] << 16))
|
||||
#define gw_mysql_get_byte4(__buffer) \
|
||||
(uint32_t)((__buffer)[0] | \
|
||||
((__buffer)[1] << 8) | \
|
||||
((__buffer)[2] << 16) | \
|
||||
((__buffer)[3] << 24))
|
||||
(uint32_t)((__buffer)[0] \
|
||||
| ((__buffer)[1] << 8) \
|
||||
| ((__buffer)[2] << 16) \
|
||||
| ((__buffer)[3] << 24))
|
||||
#define gw_mysql_get_byte8(__buffer) \
|
||||
((uint64_t)(__buffer)[0] | \
|
||||
((uint64_t)(__buffer)[1] << 8) | \
|
||||
((uint64_t)(__buffer)[2] << 16) | \
|
||||
((uint64_t)(__buffer)[3] << 24) | \
|
||||
((uint64_t)(__buffer)[4] << 32) | \
|
||||
((uint64_t)(__buffer)[5] << 40) | \
|
||||
((uint64_t)(__buffer)[6] << 48) | \
|
||||
((uint64_t)(__buffer)[7] << 56))
|
||||
((uint64_t)(__buffer)[0] \
|
||||
| ((uint64_t)(__buffer)[1] << 8) \
|
||||
| ((uint64_t)(__buffer)[2] << 16) \
|
||||
| ((uint64_t)(__buffer)[3] << 24) \
|
||||
| ((uint64_t)(__buffer)[4] << 32) \
|
||||
| ((uint64_t)(__buffer)[5] << 40) \
|
||||
| ((uint64_t)(__buffer)[6] << 48) \
|
||||
| ((uint64_t)(__buffer)[7] << 56))
|
||||
|
||||
/** MySQL protocol constants */
|
||||
typedef enum
|
||||
{
|
||||
GW_MYSQL_CAPABILITIES_NONE = 0,
|
||||
GW_MYSQL_CAPABILITIES_NONE = 0,
|
||||
/** This is sent by pre-10.2 clients */
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL = (1 << 0),
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS = (1 << 1),
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG = (1 << 2),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB = (1 << 3),
|
||||
GW_MYSQL_CAPABILITIES_NO_SCHEMA = (1 << 4),
|
||||
GW_MYSQL_CAPABILITIES_COMPRESS = (1 << 5),
|
||||
GW_MYSQL_CAPABILITIES_ODBC = (1 << 6),
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES = (1 << 7),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SPACE = (1 << 8),
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 = (1 << 9),
|
||||
GW_MYSQL_CAPABILITIES_INTERACTIVE = (1 << 10),
|
||||
GW_MYSQL_CAPABILITIES_SSL = (1 << 11),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE = (1 << 12),
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS = (1 << 13),
|
||||
GW_MYSQL_CAPABILITIES_RESERVED = (1 << 14),
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION = (1 << 15),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS = (1 << 16),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS = (1 << 17),
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS = (1 << 18),
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH = (1 << 19),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_ATTRS = (1 << 20),
|
||||
GW_MYSQL_CAPABILITIES_AUTH_LENENC_DATA = (1 << 21),
|
||||
GW_MYSQL_CAPABILITIES_EXPIRE_PASSWORD = (1 << 22),
|
||||
GW_MYSQL_CAPABILITIES_SESSION_TRACK = (1 << 23),
|
||||
GW_MYSQL_CAPABILITIES_DEPRECATE_EOF = (1 << 24),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL = (1 << 0),
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS = (1 << 1),
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG = (1 << 2),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB = (1 << 3),
|
||||
GW_MYSQL_CAPABILITIES_NO_SCHEMA = (1 << 4),
|
||||
GW_MYSQL_CAPABILITIES_COMPRESS = (1 << 5),
|
||||
GW_MYSQL_CAPABILITIES_ODBC = (1 << 6),
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES = (1 << 7),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SPACE = (1 << 8),
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 = (1 << 9),
|
||||
GW_MYSQL_CAPABILITIES_INTERACTIVE = (1 << 10),
|
||||
GW_MYSQL_CAPABILITIES_SSL = (1 << 11),
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE = (1 << 12),
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS = (1 << 13),
|
||||
GW_MYSQL_CAPABILITIES_RESERVED = (1 << 14),
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION = (1 << 15),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS = (1 << 16),
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS = (1 << 17),
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS = (1 << 18),
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH = (1 << 19),
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_ATTRS = (1 << 20),
|
||||
GW_MYSQL_CAPABILITIES_AUTH_LENENC_DATA = (1 << 21),
|
||||
GW_MYSQL_CAPABILITIES_EXPIRE_PASSWORD = (1 << 22),
|
||||
GW_MYSQL_CAPABILITIES_SESSION_TRACK = (1 << 23),
|
||||
GW_MYSQL_CAPABILITIES_DEPRECATE_EOF = (1 << 24),
|
||||
GW_MYSQL_CAPABILITIES_SSL_VERIFY_SERVER_CERT = (1 << 30),
|
||||
GW_MYSQL_CAPABILITIES_REMEMBER_OPTIONS = (1 << 31),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT = (
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL |
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS |
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG |
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB |
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES |
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH |
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS |
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION),
|
||||
GW_MYSQL_CAPABILITIES_REMEMBER_OPTIONS = (1 << 31),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT = (
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL
|
||||
| GW_MYSQL_CAPABILITIES_FOUND_ROWS
|
||||
| GW_MYSQL_CAPABILITIES_LONG_FLAG
|
||||
| GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB
|
||||
| GW_MYSQL_CAPABILITIES_LOCAL_FILES
|
||||
| GW_MYSQL_CAPABILITIES_PLUGIN_AUTH
|
||||
| GW_MYSQL_CAPABILITIES_TRANSACTIONS
|
||||
| GW_MYSQL_CAPABILITIES_PROTOCOL_41
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_SECURE_CONNECTION),
|
||||
GW_MYSQL_CAPABILITIES_SERVER = (
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL |
|
||||
GW_MYSQL_CAPABILITIES_FOUND_ROWS |
|
||||
GW_MYSQL_CAPABILITIES_LONG_FLAG |
|
||||
GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB |
|
||||
GW_MYSQL_CAPABILITIES_NO_SCHEMA |
|
||||
GW_MYSQL_CAPABILITIES_ODBC |
|
||||
GW_MYSQL_CAPABILITIES_LOCAL_FILES |
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SPACE |
|
||||
GW_MYSQL_CAPABILITIES_PROTOCOL_41 |
|
||||
GW_MYSQL_CAPABILITIES_INTERACTIVE |
|
||||
GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE |
|
||||
GW_MYSQL_CAPABILITIES_TRANSACTIONS |
|
||||
GW_MYSQL_CAPABILITIES_RESERVED |
|
||||
GW_MYSQL_CAPABILITIES_SECURE_CONNECTION |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS |
|
||||
GW_MYSQL_CAPABILITIES_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS |
|
||||
GW_MYSQL_CAPABILITIES_PLUGIN_AUTH),
|
||||
GW_MYSQL_CAPABILITIES_CLIENT_MYSQL
|
||||
| GW_MYSQL_CAPABILITIES_FOUND_ROWS
|
||||
| GW_MYSQL_CAPABILITIES_LONG_FLAG
|
||||
| GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB
|
||||
| GW_MYSQL_CAPABILITIES_NO_SCHEMA
|
||||
| GW_MYSQL_CAPABILITIES_ODBC
|
||||
| GW_MYSQL_CAPABILITIES_LOCAL_FILES
|
||||
| GW_MYSQL_CAPABILITIES_IGNORE_SPACE
|
||||
| GW_MYSQL_CAPABILITIES_PROTOCOL_41
|
||||
| GW_MYSQL_CAPABILITIES_INTERACTIVE
|
||||
| GW_MYSQL_CAPABILITIES_IGNORE_SIGPIPE
|
||||
| GW_MYSQL_CAPABILITIES_TRANSACTIONS
|
||||
| GW_MYSQL_CAPABILITIES_RESERVED
|
||||
| GW_MYSQL_CAPABILITIES_SECURE_CONNECTION
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS
|
||||
| GW_MYSQL_CAPABILITIES_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_PS_MULTI_RESULTS
|
||||
| GW_MYSQL_CAPABILITIES_PLUGIN_AUTH),
|
||||
} gw_mysql_capabilities_t;
|
||||
|
||||
/**
|
||||
@ -286,19 +289,19 @@ typedef enum
|
||||
MXS_COM_TABLE_DUMP,
|
||||
MXS_COM_CONNECT_OUT = 20,
|
||||
MXS_COM_REGISTER_SLAVE,
|
||||
MXS_COM_STMT_PREPARE = 22,
|
||||
MXS_COM_STMT_EXECUTE = 23,
|
||||
MXS_COM_STMT_PREPARE = 22,
|
||||
MXS_COM_STMT_EXECUTE = 23,
|
||||
MXS_COM_STMT_SEND_LONG_DATA = 24,
|
||||
MXS_COM_STMT_CLOSE = 25,
|
||||
MXS_COM_STMT_RESET = 26,
|
||||
MXS_COM_SET_OPTION = 27,
|
||||
MXS_COM_STMT_FETCH = 28,
|
||||
MXS_COM_STMT_BULK_EXECUTE = 0xfa,
|
||||
MXS_COM_STMT_CLOSE = 25,
|
||||
MXS_COM_STMT_RESET = 26,
|
||||
MXS_COM_SET_OPTION = 27,
|
||||
MXS_COM_STMT_FETCH = 28,
|
||||
MXS_COM_STMT_BULK_EXECUTE = 0xfa,
|
||||
MXS_COM_DAEMON,
|
||||
MXS_COM_END
|
||||
} mxs_mysql_cmd_t;
|
||||
|
||||
static const mxs_mysql_cmd_t MXS_COM_UNDEFINED = (mxs_mysql_cmd_t) - 1;
|
||||
static const mxs_mysql_cmd_t MXS_COM_UNDEFINED = (mxs_mysql_cmd_t) -1;
|
||||
|
||||
/**
|
||||
* A GWBUF property with this name will contain the latest GTID in string form.
|
||||
@ -314,23 +317,25 @@ static const char* const MXS_LAST_GTID = "last_gtid";
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int fd; /*< The socket descriptor */
|
||||
struct dcb* owner_dcb; /*< The DCB of the socket we are running on */
|
||||
mxs_mysql_cmd_t current_command; /*< Current command being executed */
|
||||
mxs_auth_state_t protocol_auth_state; /*< Authentication status */
|
||||
mysql_protocol_state_t protocol_state; /*< Protocol struct status */
|
||||
uint8_t scramble[MYSQL_SCRAMBLE_LEN]; /*< server scramble, created or received */
|
||||
uint32_t server_capabilities; /*< server capabilities, created or received */
|
||||
uint32_t client_capabilities; /*< client capabilities, created or received */
|
||||
uint32_t extra_capabilities; /*< MariaDB 10.2 capabilities */
|
||||
uint64_t thread_id; /*< MySQL Thread ID. Send only 32bits in handshake. */
|
||||
unsigned int charset; /*< MySQL character set at connect time */
|
||||
int ignore_replies; /*< How many replies should be discarded */
|
||||
GWBUF* stored_query; /*< Temporarily stored queries */
|
||||
bool collect_result; /*< Collect the next result set as one buffer */
|
||||
int fd; /*< The socket descriptor */
|
||||
struct dcb* owner_dcb; /*< The DCB of the socket we are running on */
|
||||
mxs_mysql_cmd_t current_command; /*< Current command being executed */
|
||||
mxs_auth_state_t protocol_auth_state; /*< Authentication status */
|
||||
mysql_protocol_state_t protocol_state; /*< Protocol struct status */
|
||||
uint8_t scramble[MYSQL_SCRAMBLE_LEN];/*< server scramble, created or received */
|
||||
uint32_t server_capabilities; /*< server capabilities, created or received */
|
||||
uint32_t client_capabilities; /*< client capabilities, created or received */
|
||||
uint32_t extra_capabilities; /*< MariaDB 10.2 capabilities */
|
||||
uint64_t thread_id; /*< MySQL Thread ID. Send only 32bits in handshake. */
|
||||
unsigned int charset; /*< MySQL character set at connect time */
|
||||
int ignore_replies; /*< How many replies should be discarded */
|
||||
GWBUF* stored_query; /*< Temporarily stored queries */
|
||||
bool collect_result; /*< Collect the next result set as one buffer */
|
||||
bool changing_user;
|
||||
uint32_t num_eof_packets; /*< Encountered eof packet number, used for check packet type */
|
||||
bool large_query; /*< Whether to ignore the command byte of the next packet*/
|
||||
uint32_t num_eof_packets; /*< Encountered eof packet number, used for check
|
||||
* packet type */
|
||||
bool large_query; /*< Whether to ignore the command byte of the next
|
||||
* packet*/
|
||||
} MySQLProtocol;
|
||||
|
||||
typedef struct
|
||||
@ -346,7 +351,7 @@ typedef struct
|
||||
#define MYSQL_REPLY_OK 0x00
|
||||
#define MYSQL_REPLY_EOF 0xfe
|
||||
#define MYSQL_REPLY_LOCAL_INFILE 0xfb
|
||||
#define MYSQL_REPLY_AUTHSWITCHREQUEST 0xfe /**< Only sent during authentication */
|
||||
#define MYSQL_REPLY_AUTHSWITCHREQUEST 0xfe /**< Only sent during authentication */
|
||||
|
||||
static inline mxs_mysql_cmd_t MYSQL_GET_COMMAND(const uint8_t* header)
|
||||
{
|
||||
@ -368,10 +373,10 @@ static inline uint32_t MYSQL_GET_PACKET_LEN(const GWBUF* buffer)
|
||||
return MYSQL_GET_PAYLOAD_LEN(GWBUF_DATA(buffer)) + MYSQL_HEADER_LEN;
|
||||
}
|
||||
|
||||
#define MYSQL_GET_ERRCODE(payload) (gw_mysql_get_byte2(&payload[5]))
|
||||
#define MYSQL_GET_STMTOK_NPARAM(payload) (gw_mysql_get_byte2(&payload[9]))
|
||||
#define MYSQL_GET_STMTOK_NATTR(payload) (gw_mysql_get_byte2(&payload[11]))
|
||||
#define MYSQL_GET_NATTR(payload) ((int)payload[4])
|
||||
#define MYSQL_GET_ERRCODE(payload) (gw_mysql_get_byte2(&payload[5]))
|
||||
#define MYSQL_GET_STMTOK_NPARAM(payload) (gw_mysql_get_byte2(&payload[9]))
|
||||
#define MYSQL_GET_STMTOK_NATTR(payload) (gw_mysql_get_byte2(&payload[11]))
|
||||
#define MYSQL_GET_NATTR(payload) ((int)payload[4])
|
||||
|
||||
static inline bool MYSQL_IS_ERROR_PACKET(const uint8_t* header)
|
||||
{
|
||||
@ -380,8 +385,8 @@ static inline bool MYSQL_IS_ERROR_PACKET(const uint8_t* header)
|
||||
|
||||
static inline bool MYSQL_IS_COM_QUIT(const uint8_t* header)
|
||||
{
|
||||
return MYSQL_GET_COMMAND(header) == MXS_COM_QUIT &&
|
||||
MYSQL_GET_PAYLOAD_LEN(header) == 1;
|
||||
return MYSQL_GET_COMMAND(header) == MXS_COM_QUIT
|
||||
&& MYSQL_GET_PAYLOAD_LEN(header) == 1;
|
||||
}
|
||||
|
||||
static inline bool MYSQL_IS_COM_INIT_DB(const uint8_t* header)
|
||||
@ -430,7 +435,7 @@ bool mysql_protocol_done(DCB* dcb);
|
||||
*
|
||||
* @return String representation of the state
|
||||
*/
|
||||
const char *gw_mysql_protocol_state2string(int state);
|
||||
const char* gw_mysql_protocol_state2string(int state);
|
||||
|
||||
/**
|
||||
* Set current command being executed
|
||||
@ -444,20 +449,20 @@ void mysql_protocol_set_current_command(DCB* dcb, mxs_mysql_cmd_t cmd);
|
||||
|
||||
GWBUF* mysql_create_com_quit(GWBUF* bufparam, int sequence);
|
||||
GWBUF* mysql_create_custom_error(int sequence, int affected_rows, const char* msg);
|
||||
GWBUF *mysql_create_standard_error(int sequence, int error_number, const char *msg);
|
||||
GWBUF* mysql_create_standard_error(int sequence, int error_number, const char* msg);
|
||||
|
||||
int mysql_send_com_quit(DCB* dcb, int sequence, GWBUF* buf);
|
||||
int mysql_send_custom_error(DCB *dcb, int sequence, int affected_rows, const char* msg);
|
||||
int mysql_send_standard_error(DCB *dcb, int sequence, int errnum, const char *msg);
|
||||
int mysql_send_auth_error(DCB *dcb, int sequence, int affected_rows, const char* msg);
|
||||
int mysql_send_custom_error(DCB* dcb, int sequence, int affected_rows, const char* msg);
|
||||
int mysql_send_standard_error(DCB* dcb, int sequence, int errnum, const char* msg);
|
||||
int mysql_send_auth_error(DCB* dcb, int sequence, int affected_rows, const char* msg);
|
||||
|
||||
char* create_auth_fail_str(char *username, char *hostaddr, bool password, char *db, int);
|
||||
char* create_auth_fail_str(char* username, char* hostaddr, bool password, char* db, int);
|
||||
|
||||
void init_response_status(GWBUF* buf, uint8_t cmd, int* npackets, size_t* nbytes);
|
||||
bool read_complete_packet(DCB *dcb, GWBUF **readbuf);
|
||||
bool gw_get_shared_session_auth_info(DCB* dcb, MYSQL_session* session);
|
||||
void mxs_mysql_get_session_track_info(GWBUF *buff, MySQLProtocol *proto);
|
||||
mysql_tx_state_t parse_trx_state(const char *str);
|
||||
void init_response_status(GWBUF* buf, uint8_t cmd, int* npackets, size_t* nbytes);
|
||||
bool read_complete_packet(DCB* dcb, GWBUF** readbuf);
|
||||
bool gw_get_shared_session_auth_info(DCB* dcb, MYSQL_session* session);
|
||||
void mxs_mysql_get_session_track_info(GWBUF* buff, MySQLProtocol* proto);
|
||||
mysql_tx_state_t parse_trx_state(const char* str);
|
||||
|
||||
/**
|
||||
* Decode server handshake
|
||||
@ -468,7 +473,7 @@ mysql_tx_state_t parse_trx_state(const char *str);
|
||||
* @return 0 on success, -1 on failure
|
||||
*
|
||||
*/
|
||||
int gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload);
|
||||
int gw_decode_mysql_server_handshake(MySQLProtocol* conn, uint8_t* payload);
|
||||
|
||||
/**
|
||||
* Create a response to the server handshake
|
||||
@ -481,14 +486,17 @@ int gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload);
|
||||
*
|
||||
* @return Generated response packet
|
||||
*/
|
||||
GWBUF* gw_generate_auth_response(MYSQL_session* client, MySQLProtocol *conn,
|
||||
bool with_ssl, bool ssl_established, uint64_t service_capabilities);
|
||||
GWBUF* gw_generate_auth_response(MYSQL_session* client,
|
||||
MySQLProtocol* conn,
|
||||
bool with_ssl,
|
||||
bool ssl_established,
|
||||
uint64_t service_capabilities);
|
||||
|
||||
/** Read the backend server's handshake */
|
||||
bool gw_read_backend_handshake(DCB *dcb, GWBUF *buffer);
|
||||
bool gw_read_backend_handshake(DCB* dcb, GWBUF* buffer);
|
||||
|
||||
/** Send the server handshake response packet to the backend server */
|
||||
mxs_auth_state_t gw_send_backend_auth(DCB *dcb);
|
||||
mxs_auth_state_t gw_send_backend_auth(DCB* dcb);
|
||||
|
||||
/** Sends a response for an AuthSwitchRequest to the default auth plugin */
|
||||
int send_mysql_native_password_response(DCB* dcb);
|
||||
@ -497,7 +505,7 @@ int send_mysql_native_password_response(DCB* dcb);
|
||||
bool send_auth_switch_request_packet(DCB* dcb);
|
||||
|
||||
/** Write an OK packet to a DCB */
|
||||
int mxs_mysql_send_ok(DCB *dcb, int sequence, uint8_t affected_rows, const char* message);
|
||||
int mxs_mysql_send_ok(DCB* dcb, int sequence, uint8_t affected_rows, const char* message);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains an OK packet
|
||||
@ -505,7 +513,7 @@ int mxs_mysql_send_ok(DCB *dcb, int sequence, uint8_t affected_rows, const char*
|
||||
* @param buffer Buffer containing a complete MySQL packet
|
||||
* @return True if the buffer contains an OK packet
|
||||
*/
|
||||
bool mxs_mysql_is_ok_packet(GWBUF *buffer);
|
||||
bool mxs_mysql_is_ok_packet(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains an ERR packet
|
||||
@ -513,7 +521,7 @@ bool mxs_mysql_is_ok_packet(GWBUF *buffer);
|
||||
* @param buffer Buffer containing a complete MySQL packet
|
||||
* @return True if the buffer contains an ERR packet
|
||||
*/
|
||||
bool mxs_mysql_is_err_packet(GWBUF *buffer);
|
||||
bool mxs_mysql_is_err_packet(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if a buffer contains a result set
|
||||
@ -522,7 +530,7 @@ bool mxs_mysql_is_err_packet(GWBUF *buffer);
|
||||
*
|
||||
* @return True if the @c buffer contains the start of a result set
|
||||
*/
|
||||
bool mxs_mysql_is_result_set(GWBUF *buffer);
|
||||
bool mxs_mysql_is_result_set(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains a LOCAL INFILE request
|
||||
@ -531,7 +539,7 @@ bool mxs_mysql_is_result_set(GWBUF *buffer);
|
||||
*
|
||||
* @return True if the buffer contains a LOCAL INFILE request
|
||||
*/
|
||||
bool mxs_mysql_is_local_infile(GWBUF *buffer);
|
||||
bool mxs_mysql_is_local_infile(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Check if the buffer contains a prepared statement OK packet
|
||||
@ -540,7 +548,7 @@ bool mxs_mysql_is_local_infile(GWBUF *buffer);
|
||||
*
|
||||
* @return True if the @c buffer contains a prepared statement OK packet
|
||||
*/
|
||||
bool mxs_mysql_is_prep_stmt_ok(GWBUF *buffer);
|
||||
bool mxs_mysql_is_prep_stmt_ok(GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* Is this a binary protocol command
|
||||
@ -558,7 +566,7 @@ bool mxs_mysql_is_ps_command(uint8_t cmd);
|
||||
*
|
||||
* @return True if more results are expected
|
||||
*/
|
||||
bool mxs_mysql_more_results_after_ok(GWBUF *buffer);
|
||||
bool mxs_mysql_more_results_after_ok(GWBUF* buffer);
|
||||
|
||||
/** Get current command for a session */
|
||||
mxs_mysql_cmd_t mxs_mysql_current_command(MXS_SESSION* session);
|
||||
@ -570,8 +578,10 @@ mxs_mysql_cmd_t mxs_mysql_current_command(MXS_SESSION* session);
|
||||
* @param npackets Pointer where the number of packets is stored
|
||||
* @param nbytes Pointer where number of bytes is stored
|
||||
*/
|
||||
void mysql_num_response_packets(GWBUF *buf, uint8_t cmd,
|
||||
int* npackets, size_t *nbytes);
|
||||
void mysql_num_response_packets(GWBUF* buf,
|
||||
uint8_t cmd,
|
||||
int* npackets,
|
||||
size_t* nbytes);
|
||||
|
||||
/**
|
||||
* @brief Return current database of the session
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <maxbase/jansson.h>
|
||||
@ -25,8 +25,8 @@ MXS_BEGIN_DECLS
|
||||
*/
|
||||
typedef enum qc_init_kind
|
||||
{
|
||||
QC_INIT_SELF = 0x01, /*< Initialize/finalize the query classifier itself. */
|
||||
QC_INIT_PLUGIN = 0x02, /*< Initialize/finalize the plugin. */
|
||||
QC_INIT_SELF = 0x01, /*< Initialize/finalize the query classifier itself. */
|
||||
QC_INIT_PLUGIN = 0x02, /*< Initialize/finalize the plugin. */
|
||||
QC_INIT_BOTH = 0x03
|
||||
} qc_init_kind_t;
|
||||
|
||||
@ -36,8 +36,8 @@ typedef enum qc_init_kind
|
||||
*/
|
||||
typedef enum qc_sql_mode
|
||||
{
|
||||
QC_SQL_MODE_DEFAULT, /*< Assume the statements are MariaDB SQL. */
|
||||
QC_SQL_MODE_ORACLE /*< Assume the statements are PL/SQL. */
|
||||
QC_SQL_MODE_DEFAULT, /*< Assume the statements are MariaDB SQL. */
|
||||
QC_SQL_MODE_ORACLE /*< Assume the statements are PL/SQL. */
|
||||
} qc_sql_mode_t;
|
||||
|
||||
/**
|
||||
@ -45,13 +45,13 @@ typedef enum qc_sql_mode
|
||||
*/
|
||||
typedef enum qc_collect_info
|
||||
{
|
||||
QC_COLLECT_ESSENTIALS = 0x00, /*< Collect only the base minimum. */
|
||||
QC_COLLECT_TABLES = 0x01, /*< Collect table names. */
|
||||
QC_COLLECT_DATABASES = 0x02, /*< Collect database names. */
|
||||
QC_COLLECT_FIELDS = 0x04, /*< Collect field information. */
|
||||
QC_COLLECT_FUNCTIONS = 0x08, /*< Collect function information. */
|
||||
QC_COLLECT_ESSENTIALS = 0x00, /*< Collect only the base minimum. */
|
||||
QC_COLLECT_TABLES = 0x01, /*< Collect table names. */
|
||||
QC_COLLECT_DATABASES = 0x02, /*< Collect database names. */
|
||||
QC_COLLECT_FIELDS = 0x04, /*< Collect field information. */
|
||||
QC_COLLECT_FUNCTIONS = 0x08, /*< Collect function information. */
|
||||
|
||||
QC_COLLECT_ALL = (QC_COLLECT_TABLES|QC_COLLECT_DATABASES|QC_COLLECT_FIELDS|QC_COLLECT_FUNCTIONS)
|
||||
QC_COLLECT_ALL = (QC_COLLECT_TABLES | QC_COLLECT_DATABASES | QC_COLLECT_FIELDS | QC_COLLECT_FUNCTIONS)
|
||||
} qc_collect_info_t;
|
||||
/**
|
||||
* qc_query_type_t defines bits that provide information about a
|
||||
@ -61,32 +61,32 @@ typedef enum qc_collect_info
|
||||
*/
|
||||
typedef enum qc_query_type
|
||||
{
|
||||
QUERY_TYPE_UNKNOWN = 0x000000, /*< Initial value, can't be tested bitwisely */
|
||||
QUERY_TYPE_LOCAL_READ = 0x000001, /*< Read non-database data, execute in MaxScale:any */
|
||||
QUERY_TYPE_READ = 0x000002, /*< Read database data:any */
|
||||
QUERY_TYPE_WRITE = 0x000004, /*< Master data will be modified:master */
|
||||
QUERY_TYPE_MASTER_READ = 0x000008, /*< Read from the master:master */
|
||||
QUERY_TYPE_SESSION_WRITE = 0x000010, /*< Session data will be modified:master or all */
|
||||
QUERY_TYPE_USERVAR_WRITE = 0x000020, /*< Write a user variable:master or all */
|
||||
QUERY_TYPE_USERVAR_READ = 0x000040, /*< Read a user variable:master or any */
|
||||
QUERY_TYPE_SYSVAR_READ = 0x000080, /*< Read a system variable:master or any */
|
||||
QUERY_TYPE_UNKNOWN = 0x000000, /*< Initial value, can't be tested bitwisely */
|
||||
QUERY_TYPE_LOCAL_READ = 0x000001, /*< Read non-database data, execute in MaxScale:any */
|
||||
QUERY_TYPE_READ = 0x000002, /*< Read database data:any */
|
||||
QUERY_TYPE_WRITE = 0x000004, /*< Master data will be modified:master */
|
||||
QUERY_TYPE_MASTER_READ = 0x000008, /*< Read from the master:master */
|
||||
QUERY_TYPE_SESSION_WRITE = 0x000010, /*< Session data will be modified:master or all */
|
||||
QUERY_TYPE_USERVAR_WRITE = 0x000020, /*< Write a user variable:master or all */
|
||||
QUERY_TYPE_USERVAR_READ = 0x000040, /*< Read a user variable:master or any */
|
||||
QUERY_TYPE_SYSVAR_READ = 0x000080, /*< Read a system variable:master or any */
|
||||
/** Not implemented yet */
|
||||
//QUERY_TYPE_SYSVAR_WRITE = 0x000100, /*< Write a system variable:master or all */
|
||||
QUERY_TYPE_GSYSVAR_READ = 0x000200, /*< Read global system variable:master or any */
|
||||
QUERY_TYPE_GSYSVAR_WRITE = 0x000400, /*< Write global system variable:master or all */
|
||||
QUERY_TYPE_BEGIN_TRX = 0x000800, /*< BEGIN or START TRANSACTION */
|
||||
QUERY_TYPE_ENABLE_AUTOCOMMIT = 0x001000, /*< SET autocommit=1 */
|
||||
QUERY_TYPE_DISABLE_AUTOCOMMIT = 0x002000, /*< SET autocommit=0 */
|
||||
QUERY_TYPE_ROLLBACK = 0x004000, /*< ROLLBACK */
|
||||
QUERY_TYPE_COMMIT = 0x008000, /*< COMMIT */
|
||||
QUERY_TYPE_PREPARE_NAMED_STMT = 0x010000, /*< Prepared stmt with name from user:all */
|
||||
QUERY_TYPE_PREPARE_STMT = 0x020000, /*< Prepared stmt with id provided by server:all */
|
||||
QUERY_TYPE_EXEC_STMT = 0x040000, /*< Execute prepared statement:master or any */
|
||||
QUERY_TYPE_CREATE_TMP_TABLE = 0x080000, /*< Create temporary table:master (could be all) */
|
||||
QUERY_TYPE_READ_TMP_TABLE = 0x100000, /*< Read temporary table:master (could be any) */
|
||||
QUERY_TYPE_SHOW_DATABASES = 0x200000, /*< Show list of databases */
|
||||
QUERY_TYPE_SHOW_TABLES = 0x400000, /*< Show list of tables */
|
||||
QUERY_TYPE_DEALLOC_PREPARE = 0x1000000 /*< Dealloc named prepare stmt:all */
|
||||
// QUERY_TYPE_SYSVAR_WRITE = 0x000100, /*< Write a system variable:master or all */
|
||||
QUERY_TYPE_GSYSVAR_READ = 0x000200, /*< Read global system variable:master or any */
|
||||
QUERY_TYPE_GSYSVAR_WRITE = 0x000400, /*< Write global system variable:master or all */
|
||||
QUERY_TYPE_BEGIN_TRX = 0x000800, /*< BEGIN or START TRANSACTION */
|
||||
QUERY_TYPE_ENABLE_AUTOCOMMIT = 0x001000, /*< SET autocommit=1 */
|
||||
QUERY_TYPE_DISABLE_AUTOCOMMIT = 0x002000, /*< SET autocommit=0 */
|
||||
QUERY_TYPE_ROLLBACK = 0x004000, /*< ROLLBACK */
|
||||
QUERY_TYPE_COMMIT = 0x008000, /*< COMMIT */
|
||||
QUERY_TYPE_PREPARE_NAMED_STMT = 0x010000, /*< Prepared stmt with name from user:all */
|
||||
QUERY_TYPE_PREPARE_STMT = 0x020000, /*< Prepared stmt with id provided by server:all */
|
||||
QUERY_TYPE_EXEC_STMT = 0x040000, /*< Execute prepared statement:master or any */
|
||||
QUERY_TYPE_CREATE_TMP_TABLE = 0x080000, /*< Create temporary table:master (could be all) */
|
||||
QUERY_TYPE_READ_TMP_TABLE = 0x100000, /*< Read temporary table:master (could be any) */
|
||||
QUERY_TYPE_SHOW_DATABASES = 0x200000, /*< Show list of databases */
|
||||
QUERY_TYPE_SHOW_TABLES = 0x400000, /*< Show list of tables */
|
||||
QUERY_TYPE_DEALLOC_PREPARE = 0x1000000 /*< Dealloc named prepare stmt:all */
|
||||
} qc_query_type_t;
|
||||
|
||||
/**
|
||||
@ -120,10 +120,10 @@ typedef enum qc_query_op
|
||||
*/
|
||||
typedef enum qc_parse_result
|
||||
{
|
||||
QC_QUERY_INVALID = 0, /*< The query was not recognized or could not be parsed. */
|
||||
QC_QUERY_TOKENIZED = 1, /*< The query was classified based on tokens; incompletely classified. */
|
||||
QC_QUERY_PARTIALLY_PARSED = 2, /*< The query was only partially parsed; incompletely classified. */
|
||||
QC_QUERY_PARSED = 3 /*< The query was fully parsed; completely classified. */
|
||||
QC_QUERY_INVALID = 0, /*< The query was not recognized or could not be parsed. */
|
||||
QC_QUERY_TOKENIZED = 1, /*< The query was classified based on tokens; incompletely classified. */
|
||||
QC_QUERY_PARTIALLY_PARSED = 2, /*< The query was only partially parsed; incompletely classified. */
|
||||
QC_QUERY_PARSED = 3 /*< The query was fully parsed; completely classified. */
|
||||
} qc_parse_result_t;
|
||||
|
||||
/**
|
||||
@ -141,9 +141,9 @@ typedef struct qc_field_info
|
||||
*/
|
||||
typedef struct qc_function_info
|
||||
{
|
||||
char* name; /** Name of function. */
|
||||
QC_FIELD_INFO* fields; /** What fields the function accesses. */
|
||||
uint32_t n_fields; /** The number of fields in @c fields. */
|
||||
char* name; /** Name of function. */
|
||||
QC_FIELD_INFO* fields; /** What fields the function accesses. */
|
||||
uint32_t n_fields;/** The number of fields in @c fields. */
|
||||
} QC_FUNCTION_INFO;
|
||||
|
||||
/**
|
||||
@ -182,7 +182,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the query classifier could be setup, otherwise
|
||||
* some specific error code.
|
||||
*/
|
||||
int32_t (*qc_setup)(qc_sql_mode_t sql_mode, const char* args);
|
||||
int32_t (* qc_setup)(qc_sql_mode_t sql_mode, const char* args);
|
||||
|
||||
/**
|
||||
* Called once at process startup, after @c qc_setup has successfully
|
||||
@ -190,24 +190,24 @@ typedef struct query_classifier
|
||||
*
|
||||
* @return QC_RESULT_OK, if the process initialization succeeded.
|
||||
*/
|
||||
int32_t (*qc_process_init)(void);
|
||||
int32_t (* qc_process_init)(void);
|
||||
|
||||
/**
|
||||
* Called once at process shutdown.
|
||||
*/
|
||||
void (*qc_process_end)(void);
|
||||
void (* qc_process_end)(void);
|
||||
|
||||
/**
|
||||
* Called once per each thread.
|
||||
*
|
||||
* @return QC_RESULT_OK, if the thread initialization succeeded.
|
||||
*/
|
||||
int32_t (*qc_thread_init)(void);
|
||||
int32_t (* qc_thread_init)(void);
|
||||
|
||||
/**
|
||||
* Called once when a thread finishes.
|
||||
*/
|
||||
void (*qc_thread_end)(void);
|
||||
void (* qc_thread_end)(void);
|
||||
|
||||
/**
|
||||
* Called to explicitly parse a statement.
|
||||
@ -221,7 +221,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_parse)(GWBUF* stmt, uint32_t collect, int32_t* result);
|
||||
int32_t (* qc_parse)(GWBUF* stmt, uint32_t collect, int32_t* result);
|
||||
|
||||
/**
|
||||
* Reports the type of the statement.
|
||||
@ -233,7 +233,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_type_mask)(GWBUF* stmt, uint32_t* type);
|
||||
int32_t (* qc_get_type_mask)(GWBUF* stmt, uint32_t* type);
|
||||
|
||||
/**
|
||||
* Reports the operation of the statement.
|
||||
@ -245,7 +245,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_operation)(GWBUF* stmt, int32_t* op);
|
||||
int32_t (* qc_get_operation)(GWBUF* stmt, int32_t* op);
|
||||
|
||||
/**
|
||||
* Reports the name of a created table.
|
||||
@ -257,7 +257,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_created_table_name)(GWBUF* stmt, char** name);
|
||||
int32_t (* qc_get_created_table_name)(GWBUF* stmt, char** name);
|
||||
|
||||
/**
|
||||
* Reports whether a statement is a "DROP TABLE ..." statement.
|
||||
@ -269,7 +269,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_is_drop_table_query)(GWBUF* stmt, int32_t* is_drop_table);
|
||||
int32_t (* qc_is_drop_table_query)(GWBUF* stmt, int32_t* is_drop_table);
|
||||
|
||||
/**
|
||||
* Returns all table names.
|
||||
@ -284,7 +284,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_table_names)(GWBUF* stmt, int32_t full_names, char*** names, int32_t *n_names);
|
||||
int32_t (* qc_get_table_names)(GWBUF* stmt, int32_t full_names, char*** names, int32_t* n_names);
|
||||
|
||||
/**
|
||||
* The canonical version of a statement.
|
||||
@ -296,7 +296,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_canonical)(GWBUF* stmt, char** canonical);
|
||||
int32_t (* qc_get_canonical)(GWBUF* stmt, char** canonical);
|
||||
|
||||
/**
|
||||
* Reports whether the statement has a where clause.
|
||||
@ -308,7 +308,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_query_has_clause)(GWBUF* stmt, int32_t* has_clause);
|
||||
int32_t (* qc_query_has_clause)(GWBUF* stmt, int32_t* has_clause);
|
||||
|
||||
/**
|
||||
* Reports the database names.
|
||||
@ -322,7 +322,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_database_names)(GWBUF* stmt, char*** names, int32_t* size);
|
||||
int32_t (* qc_get_database_names)(GWBUF* stmt, char*** names, int32_t* size);
|
||||
|
||||
/**
|
||||
* Reports the prepare name.
|
||||
@ -334,7 +334,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_prepare_name)(GWBUF* stmt, char** name);
|
||||
int32_t (* qc_get_prepare_name)(GWBUF* stmt, char** name);
|
||||
|
||||
/**
|
||||
* Reports field information.
|
||||
@ -346,7 +346,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_field_info)(GWBUF* stmt, const QC_FIELD_INFO** infos, uint32_t* n_infos);
|
||||
int32_t (* qc_get_field_info)(GWBUF* stmt, const QC_FIELD_INFO** infos, uint32_t* n_infos);
|
||||
|
||||
/**
|
||||
* The canonical version of a statement.
|
||||
@ -358,7 +358,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_function_info)(GWBUF* stmt, const QC_FUNCTION_INFO** infos, uint32_t* n_infos);
|
||||
int32_t (* qc_get_function_info)(GWBUF* stmt, const QC_FUNCTION_INFO** infos, uint32_t* n_infos);
|
||||
|
||||
/**
|
||||
* Return the preparable statement of a PREPARE statement.
|
||||
@ -375,7 +375,7 @@ typedef struct query_classifier
|
||||
* @return QC_RESULT_OK, if the parsing was not aborted due to resource
|
||||
* exhaustion or equivalent.
|
||||
*/
|
||||
int32_t (*qc_get_preparable_stmt)(GWBUF* stmt, GWBUF** preparable_stmt);
|
||||
int32_t (* qc_get_preparable_stmt)(GWBUF* stmt, GWBUF** preparable_stmt);
|
||||
|
||||
/**
|
||||
* Set the version of the server. The version may affect how a statement
|
||||
@ -385,7 +385,7 @@ typedef struct query_classifier
|
||||
* @param version Version encoded as MariaDB encodes the version, i.e.:
|
||||
* version = major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
void (*qc_set_server_version)(uint64_t version);
|
||||
void (* qc_set_server_version)(uint64_t version);
|
||||
|
||||
/**
|
||||
* Get the thread specific version assumed of the server. If the version has
|
||||
@ -394,7 +394,7 @@ typedef struct query_classifier
|
||||
* @param version The version encoded as MariaDB encodes the version, i.e.:
|
||||
* version = major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
void (*qc_get_server_version)(uint64_t* version);
|
||||
void (* qc_get_server_version)(uint64_t* version);
|
||||
|
||||
/**
|
||||
* Gets the sql mode of the *calling* thread.
|
||||
@ -403,7 +403,7 @@ typedef struct query_classifier
|
||||
*
|
||||
* @return QC_RESULT_OK
|
||||
*/
|
||||
int32_t (*qc_get_sql_mode)(qc_sql_mode_t* sql_mode);
|
||||
int32_t (* qc_get_sql_mode)(qc_sql_mode_t* sql_mode);
|
||||
|
||||
/**
|
||||
* Sets the sql mode for the *calling* thread.
|
||||
@ -412,7 +412,7 @@ typedef struct query_classifier
|
||||
*
|
||||
* @return QC_RESULT_OK if @sql_mode is valid, otherwise QC_RESULT_ERROR.
|
||||
*/
|
||||
int32_t (*qc_set_sql_mode)(qc_sql_mode_t sql_mode);
|
||||
int32_t (* qc_set_sql_mode)(qc_sql_mode_t sql_mode);
|
||||
|
||||
/**
|
||||
* Dups the provided info object. After having been dupped, the info object
|
||||
@ -422,7 +422,7 @@ typedef struct query_classifier
|
||||
*
|
||||
* @return The same info that was provided as argument.
|
||||
*/
|
||||
QC_STMT_INFO* (*qc_info_dup)(QC_STMT_INFO* info);
|
||||
QC_STMT_INFO* (*qc_info_dup)(QC_STMT_INFO * info);
|
||||
|
||||
/**
|
||||
* Closes a dupped info object. After the info object has been closed, it must
|
||||
@ -430,7 +430,7 @@ typedef struct query_classifier
|
||||
*
|
||||
* @param info The info to be closed.
|
||||
*/
|
||||
void (*qc_info_close)(QC_STMT_INFO* info);
|
||||
void (* qc_info_close)(QC_STMT_INFO* info);
|
||||
} QUERY_CLASSIFIER;
|
||||
|
||||
/**
|
||||
@ -438,7 +438,7 @@ typedef struct query_classifier
|
||||
*/
|
||||
typedef struct QC_CACHE_PROPERTIES
|
||||
{
|
||||
int64_t max_size; /** The maximum size of the cache. */
|
||||
int64_t max_size; /** The maximum size of the cache. */
|
||||
} QC_CACHE_PROPERTIES;
|
||||
|
||||
/**
|
||||
@ -446,11 +446,11 @@ typedef struct QC_CACHE_PROPERTIES
|
||||
*/
|
||||
typedef struct QC_CACHE_STATS
|
||||
{
|
||||
int64_t size; /** The current size of the cache. */
|
||||
int64_t inserts; /** The number of inserts. */
|
||||
int64_t hits; /** The number of hits. */
|
||||
int64_t misses; /** The number of misses. */
|
||||
int64_t evictions; /** The number of evictions. */
|
||||
int64_t size; /** The current size of the cache. */
|
||||
int64_t inserts; /** The number of inserts. */
|
||||
int64_t hits; /** The number of hits. */
|
||||
int64_t misses; /** The number of misses. */
|
||||
int64_t evictions; /** The number of evictions. */
|
||||
} QC_CACHE_STATS;
|
||||
|
||||
/**
|
||||
@ -475,7 +475,8 @@ typedef struct QC_CACHE_STATS
|
||||
*/
|
||||
bool qc_setup(const QC_CACHE_PROPERTIES* cache_properties,
|
||||
qc_sql_mode_t sql_mode,
|
||||
const char* plugin_name, const char* plugin_args);
|
||||
const char* plugin_name,
|
||||
const char* plugin_args);
|
||||
|
||||
/**
|
||||
* Loads and setups the default query classifier, and performs
|
||||
@ -497,8 +498,8 @@ bool qc_setup(const QC_CACHE_PROPERTIES* cache_properties,
|
||||
*/
|
||||
bool qc_init(const QC_CACHE_PROPERTIES* cache_properties,
|
||||
qc_sql_mode_t sql_mode,
|
||||
const char* plugin_name,
|
||||
const char* plugin_args);
|
||||
const char* plugin_name,
|
||||
const char* plugin_args);
|
||||
|
||||
/**
|
||||
* Performs thread and process finalization.
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <string>
|
||||
@ -27,7 +27,7 @@ namespace maxscale
|
||||
class QueryClassifier
|
||||
{
|
||||
QueryClassifier(const QueryClassifier&) = delete;
|
||||
QueryClassifier& operator = (const QueryClassifier&) = delete;
|
||||
QueryClassifier& operator=(const QueryClassifier&) = delete;
|
||||
|
||||
public:
|
||||
class RouteInfo
|
||||
@ -35,7 +35,7 @@ public:
|
||||
public:
|
||||
RouteInfo();
|
||||
RouteInfo(uint32_t target,
|
||||
uint8_t command,
|
||||
uint8_t command,
|
||||
uint32_t type_mask,
|
||||
uint32_t stmt_id);
|
||||
|
||||
@ -92,10 +92,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t m_target; /**< Route target type, TARGET_UNDEFINED for unknown */
|
||||
uint8_t m_command; /**< The command byte, 0xff for unknown commands */
|
||||
uint32_t m_type_mask; /**< The query type, QUERY_TYPE_UNKNOWN for unknown types*/
|
||||
uint32_t m_stmt_id; /**< Prepared statement ID, 0 for unknown */
|
||||
uint32_t m_target; /**< Route target type, TARGET_UNDEFINED for unknown */
|
||||
uint8_t m_command; /**< The command byte, 0xff for unknown commands */
|
||||
uint32_t m_type_mask; /**< The query type, QUERY_TYPE_UNKNOWN for unknown types*/
|
||||
uint32_t m_stmt_id; /**< Prepared statement ID, 0 for unknown */
|
||||
};
|
||||
|
||||
class Handler
|
||||
@ -123,39 +123,39 @@ public:
|
||||
|
||||
static bool target_is_master(uint32_t t)
|
||||
{
|
||||
return (t & TARGET_MASTER);
|
||||
return t & TARGET_MASTER;
|
||||
}
|
||||
|
||||
static bool target_is_slave(uint32_t t)
|
||||
{
|
||||
return (t & TARGET_SLAVE);
|
||||
return t & TARGET_SLAVE;
|
||||
}
|
||||
|
||||
static bool target_is_named_server(uint32_t t)
|
||||
{
|
||||
return (t & TARGET_NAMED_SERVER);
|
||||
return t & TARGET_NAMED_SERVER;
|
||||
}
|
||||
|
||||
static bool target_is_all(uint32_t t)
|
||||
{
|
||||
return (t & TARGET_ALL);
|
||||
return t & TARGET_ALL;
|
||||
}
|
||||
|
||||
static bool target_is_rlag_max(uint32_t t)
|
||||
{
|
||||
return (t & TARGET_RLAG_MAX);
|
||||
return t & TARGET_RLAG_MAX;
|
||||
}
|
||||
|
||||
static bool target_is_last_used(uint32_t t)
|
||||
{
|
||||
return (t & TARGET_LAST_USED);
|
||||
return t & TARGET_LAST_USED;
|
||||
}
|
||||
|
||||
enum current_target_t
|
||||
{
|
||||
CURRENT_TARGET_UNDEFINED, /**< Current target has not been set. */
|
||||
CURRENT_TARGET_MASTER, /**< Current target is master */
|
||||
CURRENT_TARGET_SLAVE /**< Current target is a slave */
|
||||
CURRENT_TARGET_UNDEFINED, /**< Current target has not been set. */
|
||||
CURRENT_TARGET_MASTER, /**< Current target is master */
|
||||
CURRENT_TARGET_SLAVE /**< Current target is a slave */
|
||||
};
|
||||
|
||||
/** States of a LOAD DATA LOCAL INFILE */
|
||||
@ -355,23 +355,22 @@ private:
|
||||
return m_pSession;
|
||||
}
|
||||
|
||||
void log_transaction_status(GWBUF *querybuf, uint32_t qtype);
|
||||
void log_transaction_status(GWBUF* querybuf, uint32_t qtype);
|
||||
|
||||
static uint32_t determine_query_type(GWBUF *querybuf, int command);
|
||||
static uint32_t determine_query_type(GWBUF* querybuf, int command);
|
||||
|
||||
void check_create_tmp_table(GWBUF *querybuf, uint32_t type);
|
||||
void check_create_tmp_table(GWBUF* querybuf, uint32_t type);
|
||||
|
||||
bool is_read_tmp_table(GWBUF *querybuf, uint32_t qtype);
|
||||
bool is_read_tmp_table(GWBUF* querybuf, uint32_t qtype);
|
||||
|
||||
void check_drop_tmp_table(GWBUF *querybuf);
|
||||
void check_drop_tmp_table(GWBUF* querybuf);
|
||||
|
||||
bool check_for_multi_stmt(GWBUF *buf, uint8_t packet_type);
|
||||
bool check_for_multi_stmt(GWBUF* buf, uint8_t packet_type);
|
||||
|
||||
current_target_t
|
||||
handle_multi_temp_and_load(QueryClassifier::current_target_t current_target,
|
||||
GWBUF *querybuf,
|
||||
uint8_t packet_type,
|
||||
uint32_t *qtype);
|
||||
current_target_t handle_multi_temp_and_load(QueryClassifier::current_target_t current_target,
|
||||
GWBUF* querybuf,
|
||||
uint8_t packet_type,
|
||||
uint32_t* qtype);
|
||||
|
||||
private:
|
||||
class PSManager;
|
||||
@ -387,16 +386,15 @@ private:
|
||||
Handler* m_pHandler;
|
||||
MXS_SESSION* m_pSession;
|
||||
mxs_target_t m_use_sql_variables_in;
|
||||
load_data_state_t m_load_data_state; /**< The LOAD DATA state */
|
||||
uint64_t m_load_data_sent; /**< How much data has been sent */
|
||||
load_data_state_t m_load_data_state; /**< The LOAD DATA state */
|
||||
uint64_t m_load_data_sent; /**< How much data has been sent */
|
||||
bool m_have_tmp_tables;
|
||||
TableSet m_tmp_tables; /**< Set of temporary tables */
|
||||
bool m_large_query; /**< Set to true when processing payloads >= 2^24 bytes */
|
||||
bool m_multi_statements_allowed; /**< Are multi-statements allowed */
|
||||
TableSet m_tmp_tables; /**< Set of temporary tables */
|
||||
bool m_large_query; /**< Set to true when processing payloads >= 2^24 bytes */
|
||||
bool m_multi_statements_allowed; /**< Are multi-statements allowed */
|
||||
SPSManager m_sPs_manager;
|
||||
HandleMap m_ps_handles; /** External ID to internal ID */
|
||||
HandleMap m_ps_handles; /** External ID to internal ID */
|
||||
RouteInfo m_route_info;
|
||||
bool m_trx_is_read_only;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -53,7 +53,7 @@ public:
|
||||
void write(DCB* dcb);
|
||||
|
||||
private:
|
||||
std::vector<std::string> m_columns;
|
||||
std::vector<std::string> m_columns;
|
||||
std::vector<std::vector<std::string>> m_rows;
|
||||
|
||||
ResultSet(std::initializer_list<std::string> names);
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file router.h - The query router public interface definition
|
||||
@ -94,7 +94,7 @@ typedef struct mxs_router_object
|
||||
*
|
||||
* @return New router instance on NULL on error
|
||||
*/
|
||||
MXS_ROUTER *(*createInstance)(SERVICE* service, MXS_CONFIG_PARAMETER* params);
|
||||
MXS_ROUTER*(*createInstance)(SERVICE * service, MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
/**
|
||||
* Called to create a new user session within the router
|
||||
@ -109,7 +109,7 @@ typedef struct mxs_router_object
|
||||
*
|
||||
* @return New router session or NULL on error
|
||||
*/
|
||||
MXS_ROUTER_SESSION *(*newSession)(MXS_ROUTER *instance, MXS_SESSION *session);
|
||||
MXS_ROUTER_SESSION*(*newSession)(MXS_ROUTER * instance, MXS_SESSION* session);
|
||||
|
||||
/**
|
||||
* @brief Called when a session is closed
|
||||
@ -119,7 +119,7 @@ typedef struct mxs_router_object
|
||||
* @param instance Router instance
|
||||
* @param router_session Router session
|
||||
*/
|
||||
void (*closeSession)(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
|
||||
void (* closeSession)(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session);
|
||||
|
||||
/**
|
||||
* @brief Called when a session is freed
|
||||
@ -129,7 +129,7 @@ typedef struct mxs_router_object
|
||||
* @param instance Router instance
|
||||
* @param router_session Router session
|
||||
*/
|
||||
void (*freeSession)(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
|
||||
void (* freeSession)(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session);
|
||||
|
||||
/**
|
||||
* @brief Called on each query that requires routing
|
||||
@ -143,7 +143,7 @@ typedef struct mxs_router_object
|
||||
* @return If successful, the function returns 1. If an error occurs
|
||||
* and the session should be closed, the function returns 0.
|
||||
*/
|
||||
int32_t (*routeQuery)(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, GWBUF *queue);
|
||||
int32_t (* routeQuery)(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session, GWBUF* queue);
|
||||
|
||||
|
||||
/**
|
||||
@ -152,7 +152,7 @@ typedef struct mxs_router_object
|
||||
* @param instance Router instance
|
||||
* @param dcb DCB where the diagnostic information should be written
|
||||
*/
|
||||
void (*diagnostics)(MXS_ROUTER *instance, DCB *dcb);
|
||||
void (* diagnostics)(MXS_ROUTER* instance, DCB* dcb);
|
||||
|
||||
/**
|
||||
* @brief Called for diagnostic output
|
||||
@ -163,7 +163,7 @@ typedef struct mxs_router_object
|
||||
*
|
||||
* @see jansson.h
|
||||
*/
|
||||
json_t* (*diagnostics_json)(const MXS_ROUTER *instance);
|
||||
json_t* (*diagnostics_json)(const MXS_ROUTER * instance);
|
||||
|
||||
/**
|
||||
* @brief Called for each reply packet
|
||||
@ -175,8 +175,10 @@ typedef struct mxs_router_object
|
||||
* @param queue Response from the server
|
||||
* @param backend_dcb The backend DCB which responded to the query
|
||||
*/
|
||||
void (*clientReply)(MXS_ROUTER* instance, MXS_ROUTER_SESSION *router_session,
|
||||
GWBUF *queue, DCB *backend_dcb);
|
||||
void (* clientReply)(MXS_ROUTER* instance,
|
||||
MXS_ROUTER_SESSION* router_session,
|
||||
GWBUF* queue,
|
||||
DCB* backend_dcb);
|
||||
|
||||
/**
|
||||
* @brief Called when a backend DCB has failed
|
||||
@ -189,12 +191,12 @@ typedef struct mxs_router_object
|
||||
*
|
||||
* @param succp Pointer to a `bool` which should be set to true for success or false for error
|
||||
*/
|
||||
void (*handleError)(MXS_ROUTER *instance,
|
||||
MXS_ROUTER_SESSION *router_session,
|
||||
GWBUF *errmsgbuf,
|
||||
DCB *backend_dcb,
|
||||
mxs_error_action_t action,
|
||||
bool* succp);
|
||||
void (* handleError)(MXS_ROUTER* instance,
|
||||
MXS_ROUTER_SESSION* router_session,
|
||||
GWBUF* errmsgbuf,
|
||||
DCB* backend_dcb,
|
||||
mxs_error_action_t action,
|
||||
bool* succp);
|
||||
|
||||
/**
|
||||
* @brief Called to obtain the capabilities of the router
|
||||
@ -203,14 +205,14 @@ typedef struct mxs_router_object
|
||||
*
|
||||
* @see routing.h
|
||||
*/
|
||||
uint64_t (*getCapabilities)(MXS_ROUTER *instance);
|
||||
uint64_t (* getCapabilities)(MXS_ROUTER* instance);
|
||||
|
||||
/**
|
||||
* @brief Called for destroying a router instance
|
||||
*
|
||||
* @param instance Router instance
|
||||
*/
|
||||
void (*destroyInstance)(MXS_ROUTER *instance);
|
||||
void (* destroyInstance)(MXS_ROUTER* instance);
|
||||
|
||||
/**
|
||||
* @brief Configure router instance at runtime
|
||||
@ -231,8 +233,7 @@ typedef struct mxs_router_object
|
||||
* failed. If reconfiguration failed, the state of the router
|
||||
* instance should not be modified.
|
||||
*/
|
||||
bool (*configureInstance)(MXS_ROUTER *instance, MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
bool (* configureInstance)(MXS_ROUTER* instance, MXS_CONFIG_PARAMETER* params);
|
||||
} MXS_ROUTER_OBJECT;
|
||||
|
||||
/**
|
||||
@ -240,7 +241,7 @@ typedef struct mxs_router_object
|
||||
* must update these versions numbers in accordance with the rules in
|
||||
* modinfo.h.
|
||||
*/
|
||||
#define MXS_ROUTER_VERSION { 4, 0, 0 }
|
||||
#define MXS_ROUTER_VERSION {4, 0, 0}
|
||||
|
||||
/**
|
||||
* Specifies capabilities specific for routers. Common capabilities
|
||||
@ -253,11 +254,11 @@ typedef struct mxs_router_object
|
||||
*/
|
||||
typedef enum router_capability
|
||||
{
|
||||
RCAP_TYPE_NO_RSESSION = 0x00010000, /**< Router does not use router sessions */
|
||||
RCAP_TYPE_NO_USERS_INIT = 0x00020000, /**< Prevent the loading of authenticator
|
||||
users when the service is started */
|
||||
RCAP_TYPE_NO_AUTH = 0x00040000, /**< No `user` or `password` parameter required */
|
||||
RCAP_TYPE_RUNTIME_CONFIG = 0x00080000, /**< Router supports runtime cofiguration */
|
||||
RCAP_TYPE_NO_RSESSION = 0x00010000, /**< Router does not use router sessions */
|
||||
RCAP_TYPE_NO_USERS_INIT = 0x00020000, /**< Prevent the loading of authenticator
|
||||
* users when the service is started */
|
||||
RCAP_TYPE_NO_AUTH = 0x00040000, /**< No `user` or `password` parameter required */
|
||||
RCAP_TYPE_RUNTIME_CONFIG = 0x00080000, /**< Router supports runtime cofiguration */
|
||||
} mxs_router_capability_t;
|
||||
|
||||
typedef enum
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxscale/router.h>
|
||||
@ -66,16 +66,16 @@ public:
|
||||
* @param action The context.
|
||||
* @param pSuccess On output, if false, the session will be terminated.
|
||||
*/
|
||||
void handleError(GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
void handleError(GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
mxs_error_action_t action,
|
||||
bool* pSuccess);
|
||||
bool* pSuccess);
|
||||
|
||||
protected:
|
||||
RouterSession(MXS_SESSION* pSession);
|
||||
|
||||
protected:
|
||||
MXS_SESSION* m_pSession; /*< The MXS_SESSION this router session is associated with. */
|
||||
MXS_SESSION* m_pSession; /*< The MXS_SESSION this router session is associated with. */
|
||||
};
|
||||
|
||||
|
||||
@ -205,12 +205,12 @@ public:
|
||||
MXS_EXCEPTION_GUARD(pRouter_session->clientReply(pPacket, pBackend));
|
||||
}
|
||||
|
||||
static void handleError(MXS_ROUTER* pInstance,
|
||||
static void handleError(MXS_ROUTER* pInstance,
|
||||
MXS_ROUTER_SESSION* pData,
|
||||
GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
mxs_error_action_t action,
|
||||
bool* pSuccess)
|
||||
GWBUF* pMessage,
|
||||
DCB* pProblem,
|
||||
mxs_error_action_t action,
|
||||
bool* pSuccess)
|
||||
{
|
||||
RouterSessionType* pRouter_session = static_cast<RouterSessionType*>(pData);
|
||||
|
||||
@ -246,7 +246,7 @@ public:
|
||||
static MXS_ROUTER_OBJECT s_object;
|
||||
|
||||
protected:
|
||||
Router(SERVICE *pService)
|
||||
Router(SERVICE* pService)
|
||||
: m_pService(pService)
|
||||
{
|
||||
}
|
||||
@ -271,6 +271,4 @@ MXS_ROUTER_OBJECT Router<RouterType, RouterSessionType>::s_object =
|
||||
&Router<RouterType, RouterSessionType>::destroyInstance,
|
||||
&Router<RouterType, RouterSessionType>::configure,
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file routing.h - Common definitions and declarations for routers and filters.
|
||||
@ -39,23 +39,22 @@ MXS_BEGIN_DECLS
|
||||
typedef enum routing_capability
|
||||
{
|
||||
/**< Statements are delivered one per buffer. */
|
||||
RCAP_TYPE_STMT_INPUT = 0x0001, /* 0b0000000000000001 */
|
||||
RCAP_TYPE_STMT_INPUT = 0x0001, /* 0b0000000000000001 */
|
||||
/**< Each delivered buffer is contiguous; implies RCAP_TYPE_STMT_INPUT. */
|
||||
RCAP_TYPE_CONTIGUOUS_INPUT = 0x0003, /* 0b0000000000000011 */
|
||||
RCAP_TYPE_CONTIGUOUS_INPUT = 0x0003, /* 0b0000000000000011 */
|
||||
/**< The transaction state and autocommit mode of the session are tracked;
|
||||
implies RCAP_TYPE_CONTIGUOUS_INPUT and RCAP_TYPE_STMT_INPUT. */
|
||||
RCAP_TYPE_TRANSACTION_TRACKING = 0x0007, /* 0b0000000000000111 */
|
||||
* implies RCAP_TYPE_CONTIGUOUS_INPUT and RCAP_TYPE_STMT_INPUT. */
|
||||
RCAP_TYPE_TRANSACTION_TRACKING = 0x0007, /* 0b0000000000000111 */
|
||||
/**< Responses are delivered one per buffer. */
|
||||
RCAP_TYPE_STMT_OUTPUT = 0x0010, /* 0b0000000000010000 */
|
||||
RCAP_TYPE_STMT_OUTPUT = 0x0010, /* 0b0000000000010000 */
|
||||
/**< Each delivered buffer is contiguous; implies RCAP_TYPE_STMT_OUTPUT. */
|
||||
RCAP_TYPE_CONTIGUOUS_OUTPUT = 0x0030, /* 0b0000000000110000 */
|
||||
RCAP_TYPE_CONTIGUOUS_OUTPUT = 0x0030, /* 0b0000000000110000 */
|
||||
/** Result sets are delivered in one buffer; implies RCAP_TYPE_STMT_OUTPUT. */
|
||||
RCAP_TYPE_RESULTSET_OUTPUT = 0x0050, /* 0b0000000001110000 */
|
||||
RCAP_TYPE_RESULTSET_OUTPUT = 0x0050, /* 0b0000000001110000 */
|
||||
/** Results are delivered as a set of complete packets */
|
||||
RCAP_TYPE_PACKET_OUTPUT = 0x0080, /* 0b0000000010000000 */
|
||||
RCAP_TYPE_PACKET_OUTPUT = 0x0080, /* 0b0000000010000000 */
|
||||
/** Track session state changes, implies packet output */
|
||||
RCAP_TYPE_SESSION_STATE_TRACKING = 0x0180, /* 0b0000000011000000 */
|
||||
|
||||
RCAP_TYPE_SESSION_STATE_TRACKING = 0x0180, /* 0b0000000011000000 */
|
||||
} mxs_routing_capability_t;
|
||||
|
||||
#define RCAP_TYPE_NONE 0
|
||||
@ -74,4 +73,3 @@ static inline bool rcap_type_required(uint64_t capabilities, uint64_t type)
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <maxbase/worker.h>
|
||||
@ -81,7 +81,7 @@ size_t mxs_rworker_broadcast_message(uint32_t msg_id, intptr_t arg1, intptr_t ar
|
||||
* @return The number of messages posted; if less that ne number of workers
|
||||
* then some postings failed.
|
||||
*/
|
||||
size_t mxs_rworker_broadcast(void (*cb)(void* data), void* data);
|
||||
size_t mxs_rworker_broadcast(void (* cb)(void* data), void* data);
|
||||
|
||||
/**
|
||||
* Add a session to the current routing worker's session container. Currently
|
||||
@ -133,7 +133,7 @@ uint64_t mxs_rworker_create_key();
|
||||
* required. This function is called by mxs_rworker_delete_data
|
||||
* when the data is deleted.
|
||||
*/
|
||||
void mxs_rworker_set_data(uint64_t key, void* data, void (*callback)(void*));
|
||||
void mxs_rworker_set_data(uint64_t key, void* data, void (* callback)(void*));
|
||||
|
||||
/**
|
||||
* Get local data from current worker
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -34,7 +34,7 @@ class RoutingWorker : public mxb::Worker
|
||||
, private MXB_POLL_DATA
|
||||
{
|
||||
RoutingWorker(const RoutingWorker&) = delete;
|
||||
RoutingWorker& operator = (const RoutingWorker&) = delete;
|
||||
RoutingWorker& operator=(const RoutingWorker&) = delete;
|
||||
|
||||
public:
|
||||
enum
|
||||
@ -45,8 +45,8 @@ public:
|
||||
typedef Registry<MXS_SESSION> SessionsById;
|
||||
typedef std::vector<DCB*> Zombies;
|
||||
|
||||
typedef std::unordered_map<uint64_t, void*> LocalData;
|
||||
typedef std::unordered_map<uint64_t, void(*)(void*)> DataDeleters;
|
||||
typedef std::unordered_map<uint64_t, void*> LocalData;
|
||||
typedef std::unordered_map<uint64_t, void (*)(void*)> DataDeleters;
|
||||
|
||||
/**
|
||||
* Initialize the routing worker mechanism.
|
||||
@ -345,7 +345,7 @@ public:
|
||||
* @param key Key acquired with create_local_data
|
||||
* @param data Data to store
|
||||
*/
|
||||
void set_data(uint64_t key, void* data, void (*callback)(void*))
|
||||
void set_data(uint64_t key, void* data, void (* callback)(void*))
|
||||
{
|
||||
if (callback)
|
||||
{
|
||||
@ -426,33 +426,33 @@ public:
|
||||
static std::unique_ptr<json_t> get_qc_stats_as_json(const char* zHost, int id);
|
||||
|
||||
private:
|
||||
const int m_id; /*< The id of the worker. */
|
||||
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map
|
||||
* should contain sessions exclusive to this
|
||||
* worker and not e.g. listener sessions. For now,
|
||||
* it's up to the protocol to decide whether a new
|
||||
* session is added to the map. */
|
||||
Zombies m_zombies; /*< DCBs to be deleted. */
|
||||
LocalData m_local_data; /*< Data local to this worker */
|
||||
DataDeleters m_data_deleters; /*< Delete functions for the local data */
|
||||
const int m_id; /*< The id of the worker. */
|
||||
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map
|
||||
* should contain sessions exclusive to this
|
||||
* worker and not e.g. listener sessions. For now,
|
||||
* it's up to the protocol to decide whether a new
|
||||
* session is added to the map. */
|
||||
Zombies m_zombies; /*< DCBs to be deleted. */
|
||||
LocalData m_local_data; /*< Data local to this worker */
|
||||
DataDeleters m_data_deleters; /*< Delete functions for the local data */
|
||||
|
||||
RoutingWorker();
|
||||
virtual ~RoutingWorker();
|
||||
|
||||
static RoutingWorker* create(int epoll_listener_fd);
|
||||
|
||||
bool pre_run(); // override
|
||||
void post_run(); // override
|
||||
void epoll_tick(); // override
|
||||
bool pre_run(); // override
|
||||
void post_run(); // override
|
||||
void epoll_tick(); // override
|
||||
|
||||
void delete_zombies();
|
||||
|
||||
static uint32_t epoll_instance_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
||||
uint32_t handle_epoll_events(uint32_t events);
|
||||
uint32_t handle_epoll_events(uint32_t events);
|
||||
};
|
||||
|
||||
// Data local to a routing worker
|
||||
template <class T>
|
||||
template<class T>
|
||||
class rworker_local
|
||||
{
|
||||
public:
|
||||
@ -461,15 +461,15 @@ public:
|
||||
rworker_local& operator=(const rworker_local&) = delete;
|
||||
|
||||
// Default initialized
|
||||
rworker_local():
|
||||
m_handle(mxs_rworker_create_key())
|
||||
rworker_local()
|
||||
: m_handle(mxs_rworker_create_key())
|
||||
{
|
||||
}
|
||||
|
||||
// Copy-constructed
|
||||
rworker_local(const T& t):
|
||||
m_handle(mxs_rworker_create_key()),
|
||||
m_value(t)
|
||||
rworker_local(const T& t)
|
||||
: m_handle(mxs_rworker_create_key())
|
||||
, m_value(t)
|
||||
{
|
||||
}
|
||||
|
||||
@ -510,9 +510,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
uint64_t m_handle; // The handle to the worker local data
|
||||
typename std::remove_const<T>::type m_value; // The master value, never used directly
|
||||
mutable std::mutex m_lock; // Protects the master value
|
||||
uint64_t m_handle; // The handle to the worker local data
|
||||
typename std::remove_const<T>::type m_value; // The master value, never used directly
|
||||
mutable std::mutex m_lock; // Protects the master value
|
||||
|
||||
private:
|
||||
|
||||
@ -554,7 +554,6 @@ private:
|
||||
delete static_cast<T*>(data);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/secrets.h - MaxScale config file password decryption
|
||||
@ -22,6 +22,6 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
char *decrypt_password(const char *);
|
||||
char* decrypt_password(const char*);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file server.h
|
||||
@ -142,21 +142,21 @@ typedef struct server
|
||||
DCB** persistent; /**< List of unused persistent connections to the server */
|
||||
uint8_t charset; /**< Server character set. Read from backend and sent to client. */
|
||||
// Statistics and events
|
||||
SERVER_STATS stats; /**< The server statistics, e.g. number of connections */
|
||||
int persistmax; /**< Maximum pool size actually achieved since startup */
|
||||
int last_event; /**< The last event that occurred on this server */
|
||||
int64_t triggered_at; /**< Time when the last event was triggered */
|
||||
SERVER_STATS stats; /**< The server statistics, e.g. number of connections */
|
||||
int persistmax; /**< Maximum pool size actually achieved since startup */
|
||||
int last_event; /**< The last event that occurred on this server */
|
||||
int64_t triggered_at; /**< Time when the last event was triggered */
|
||||
// Status descriptors. Updated automatically by a monitor or manually by the admin
|
||||
uint64_t status; /**< Current status flag bitmap */
|
||||
int maint_request; /**< Is admin requesting Maintenance=ON/OFF on the
|
||||
uint64_t status; /**< Current status flag bitmap */
|
||||
int maint_request; /**< Is admin requesting Maintenance=ON/OFF on the
|
||||
* server? */
|
||||
char version_string[MAX_SERVER_VERSION_LEN]; /**< Server version string as given by backend */
|
||||
uint64_t version; /**< Server version numeric representation */
|
||||
server_type_t server_type; /**< Server type (MariaDB or MySQL), deduced from
|
||||
* version string */
|
||||
long node_id; /**< Node id, server_id for M/S or local_index for
|
||||
long node_id; /**< Node id, server_id for M/S or local_index for
|
||||
* Galera */
|
||||
int rlag; /**< Replication Lag for Master/Slave replication
|
||||
int rlag; /**< Replication Lag for Master/Slave replication
|
||||
* */
|
||||
unsigned long node_ts; /**< Last timestamp set from M/S monitor module */
|
||||
long master_id; /**< Master server id of this node */
|
||||
@ -196,33 +196,33 @@ typedef struct server
|
||||
(server_is_master(s) ? "RUNNING MASTER" \
|
||||
: (server_is_slave(s) ? "RUNNING SLAVE" \
|
||||
: (server_is_joined(s) ? "RUNNING JOINED" \
|
||||
: (server_is_ndb(s) ? \
|
||||
"RUNNING NDB" \
|
||||
: (( \
|
||||
server_is_running( \
|
||||
s) \
|
||||
&& \
|
||||
server_is_in_maint( \
|
||||
s)) \
|
||||
? \
|
||||
"RUNNING MAINTENANCE" \
|
||||
: ( \
|
||||
server_is_relay( \
|
||||
s) \
|
||||
? \
|
||||
"RUNNING RELAY" \
|
||||
: ( \
|
||||
server_is_usable( \
|
||||
s) \
|
||||
? \
|
||||
"RUNNING (only)" \
|
||||
: ( \
|
||||
server_is_down( \
|
||||
s) \
|
||||
? \
|
||||
"DOWN" \
|
||||
: \
|
||||
"UNKNOWN STATUS"))))))))
|
||||
: (server_is_ndb(s) \
|
||||
? "RUNNING NDB" \
|
||||
: (( \
|
||||
server_is_running( \
|
||||
s) \
|
||||
&& \
|
||||
server_is_in_maint( \
|
||||
s)) \
|
||||
? \
|
||||
"RUNNING MAINTENANCE" \
|
||||
: ( \
|
||||
server_is_relay( \
|
||||
s) \
|
||||
? \
|
||||
"RUNNING RELAY" \
|
||||
: ( \
|
||||
server_is_usable( \
|
||||
s) \
|
||||
? \
|
||||
"RUNNING (only)" \
|
||||
: ( \
|
||||
server_is_down( \
|
||||
s) \
|
||||
? \
|
||||
"DOWN" \
|
||||
: \
|
||||
"UNKNOWN STATUS"))))))))
|
||||
|
||||
/**
|
||||
* Is the server valid and active?
|
||||
@ -447,7 +447,7 @@ bool server_remove_parameter(SERVER* server, const char* name);
|
||||
* @param name Parameter to set
|
||||
* @param value Value of parameter
|
||||
*/
|
||||
void server_set_parameter(SERVER *server, const char *name, const char *value);
|
||||
void server_set_parameter(SERVER* server, const char* name, const char* value);
|
||||
|
||||
/**
|
||||
* @brief Check if a server points to a local MaxScale service
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -19,6 +19,6 @@
|
||||
|
||||
namespace maxscale
|
||||
{
|
||||
bool server_set_status(SERVER *server, int bit, std::string* errmsg_out = NULL);
|
||||
bool server_clear_status(SERVER *server, int bit, std::string* errmsg_out = NULL);
|
||||
bool server_set_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||
bool server_clear_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file service.h
|
||||
@ -43,10 +43,10 @@ struct mxs_router;
|
||||
struct mxs_router_object;
|
||||
struct users;
|
||||
|
||||
#define MAX_SERVICE_USER_LEN 1024
|
||||
#define MAX_SERVICE_USER_LEN 1024
|
||||
#define MAX_SERVICE_PASSWORD_LEN 1024
|
||||
#define MAX_SERVICE_WEIGHTBY_LEN 1024
|
||||
#define MAX_SERVICE_VERSION_LEN 1024
|
||||
#define MAX_SERVICE_VERSION_LEN 1024
|
||||
|
||||
/**
|
||||
* The service statistics structure
|
||||
@ -61,11 +61,11 @@ typedef struct
|
||||
|
||||
typedef struct server_ref_t
|
||||
{
|
||||
struct server_ref_t *next; /**< Next server reference */
|
||||
SERVER* server; /**< The actual server */
|
||||
double inv_weight; /**< Inverse of weight in the range [0..1], 0 is best. */
|
||||
int connections; /**< Number of connections created through this reference */
|
||||
bool active; /**< Whether this reference is valid and in use*/
|
||||
struct server_ref_t* next; /**< Next server reference */
|
||||
SERVER* server; /**< The actual server */
|
||||
double inv_weight; /**< Inverse of weight in the range [0..1], 0 is best. */
|
||||
int connections; /**< Number of connections created through this reference */
|
||||
bool active; /**< Whether this reference is valid and in use*/
|
||||
} SERVER_REF;
|
||||
|
||||
/** Returns true if the two server "scores" are within 1/(see code) of each other.
|
||||
@ -76,14 +76,14 @@ typedef struct server_ref_t
|
||||
*/
|
||||
inline bool almost_equal_server_scores(double lhs, double rhs)
|
||||
{
|
||||
constexpr double div = 100; // within 1% of each other.
|
||||
constexpr double div = 100; // within 1% of each other.
|
||||
return std::abs(lhs - rhs) < std::abs(std::max(lhs, rhs)) * (1 / div);
|
||||
}
|
||||
|
||||
/** Macro to check whether a SERVER_REF is active */
|
||||
#define SERVER_REF_IS_ACTIVE(ref) (ref->active && server_is_active(ref->server))
|
||||
|
||||
#define SERVICE_MAX_RETRY_INTERVAL 3600 /*< The maximum interval between service start retries */
|
||||
#define SERVICE_MAX_RETRY_INTERVAL 3600 /*< The maximum interval between service start retries */
|
||||
|
||||
/** Value of service timeout if timeout checks are disabled */
|
||||
#define SERVICE_NO_SESSION_TIMEOUT 0
|
||||
@ -95,8 +95,8 @@ inline bool almost_equal_server_scores(double lhs, double rhs)
|
||||
#define SERVICE_PARAM_UNINIT -1
|
||||
|
||||
/* Refresh rate limits for load users from database */
|
||||
#define USERS_REFRESH_TIME_DEFAULT 30 /* Allowed time interval (in seconds) after last update*/
|
||||
#define USERS_REFRESH_TIME_MIN 10 /* Minimum allowed time interval (in seconds)*/
|
||||
#define USERS_REFRESH_TIME_DEFAULT 30 /* Allowed time interval (in seconds) after last update*/
|
||||
#define USERS_REFRESH_TIME_MIN 10 /* Minimum allowed time interval (in seconds)*/
|
||||
|
||||
/** Default timeout values used by the connections which fetch user authentication data */
|
||||
#define DEFAULT_AUTH_CONNECT_TIMEOUT 3
|
||||
@ -112,38 +112,57 @@ inline bool almost_equal_server_scores(double lhs, double rhs)
|
||||
*/
|
||||
typedef struct service
|
||||
{
|
||||
const char* name; /**< The service name */
|
||||
int state; /**< The service state */
|
||||
int client_count; /**< Number of connected clients */
|
||||
int max_connections; /**< Maximum client connections */
|
||||
SERV_LISTENER *ports; /**< Linked list of ports and protocols
|
||||
* that this service will listen on */
|
||||
const char* routerModule; /**< Name of router module to use */
|
||||
struct mxs_router_object *router; /**< The router we are using */
|
||||
struct mxs_router *router_instance;/**< The router instance for this service */
|
||||
char version_string[MAX_SERVICE_VERSION_LEN]; /**< version string for this service listeners */
|
||||
SERVER_REF *dbref; /**< server references */
|
||||
int n_dbref; /**< Number of server references */
|
||||
char user[MAX_SERVICE_USER_LEN]; /**< The user name to use to extract information */
|
||||
char password[MAX_SERVICE_PASSWORD_LEN]; /**< The authentication data requied */
|
||||
SERVICE_STATS stats; /**< The service statistics */
|
||||
bool enable_root; /**< Allow root user access */
|
||||
bool localhost_match_wildcard_host; /**< Match localhost against wildcard */
|
||||
MXS_CONFIG_PARAMETER* svc_config_param;/**< list of config params and values */
|
||||
int svc_config_version; /**< Version number of configuration */
|
||||
bool svc_do_shutdown; /**< tells the service to exit loops etc. */
|
||||
bool users_from_all; /**< Load users from one server or all of them */
|
||||
bool strip_db_esc; /**< Remove the '\' characters from database names
|
||||
* when querying them from the server. MySQL Workbench seems
|
||||
* to escape at least the underscore character. */
|
||||
int64_t conn_idle_timeout; /**< Session timeout in seconds */
|
||||
char weightby[MAX_SERVICE_WEIGHTBY_LEN]; /**< Service weighting parameter name */
|
||||
bool retry_start; /**< If starting of the service should be retried later */
|
||||
bool log_auth_warnings; /**< Log authentication failures and warnings */
|
||||
uint64_t capabilities; /**< The capabilities of the service, @see enum routing_capability */
|
||||
int max_retry_interval; /**< Maximum retry interval */
|
||||
bool session_track_trx_state; /**< Get transaction state via session track mechanism */
|
||||
int active; /**< Whether the service is still active */
|
||||
const char* name; /**< The service name */
|
||||
int state; /**< The service state */
|
||||
int client_count; /**< Number of connected clients */
|
||||
int max_connections; /**< Maximum client connections */
|
||||
SERV_LISTENER* ports; /**< Linked list of ports and
|
||||
* protocols
|
||||
* that this service will listen on */
|
||||
const char* routerModule; /**< Name of router module to use */
|
||||
struct mxs_router_object* router; /**< The router we are using */
|
||||
struct mxs_router* router_instance; /**< The router instance for this
|
||||
* service */
|
||||
char version_string[MAX_SERVICE_VERSION_LEN]; /**< version string for this service
|
||||
* listeners */
|
||||
SERVER_REF* dbref; /**< server references */
|
||||
int n_dbref; /**< Number of server references */
|
||||
char user[MAX_SERVICE_USER_LEN]; /**< The user name to use to extract
|
||||
* information */
|
||||
char password[MAX_SERVICE_PASSWORD_LEN]; /**< The authentication data requied
|
||||
* */
|
||||
SERVICE_STATS stats; /**< The service statistics */
|
||||
bool enable_root; /**< Allow root user access */
|
||||
bool localhost_match_wildcard_host; /**< Match localhost against wildcard
|
||||
* */
|
||||
MXS_CONFIG_PARAMETER* svc_config_param; /**< list of config params and values
|
||||
* */
|
||||
int svc_config_version; /**< Version number of configuration
|
||||
* */
|
||||
bool svc_do_shutdown; /**< tells the service to exit loops
|
||||
* etc. */
|
||||
bool users_from_all; /**< Load users from one server or all
|
||||
* of them */
|
||||
bool strip_db_esc; /**< Remove the '\' characters from
|
||||
* database names
|
||||
* when querying them from the server.
|
||||
*MySQL Workbench seems
|
||||
* to escape at least the underscore
|
||||
*character. */
|
||||
int64_t conn_idle_timeout; /**< Session timeout in seconds */
|
||||
char weightby[MAX_SERVICE_WEIGHTBY_LEN]; /**< Service weighting parameter name
|
||||
* */
|
||||
bool retry_start; /**< If starting of the service should
|
||||
* be retried later */
|
||||
bool log_auth_warnings; /**< Log authentication failures and
|
||||
* warnings */
|
||||
uint64_t capabilities; /**< The capabilities of the service,
|
||||
* @see enum routing_capability */
|
||||
int max_retry_interval; /**< Maximum retry interval */
|
||||
bool session_track_trx_state; /**< Get transaction state via session
|
||||
* track mechanism */
|
||||
int active; /**< Whether the service is still
|
||||
* active */
|
||||
} SERVICE;
|
||||
|
||||
typedef enum count_spec_t
|
||||
@ -154,10 +173,10 @@ typedef enum count_spec_t
|
||||
COUNT_ATMOST
|
||||
} count_spec_t;
|
||||
|
||||
#define SERVICE_STATE_ALLOC 1 /**< The service has been allocated */
|
||||
#define SERVICE_STATE_STARTED 2 /**< The service has been started */
|
||||
#define SERVICE_STATE_FAILED 3 /**< The service failed to start */
|
||||
#define SERVICE_STATE_STOPPED 4 /**< The service has been stopped */
|
||||
#define SERVICE_STATE_ALLOC 1 /**< The service has been allocated */
|
||||
#define SERVICE_STATE_STARTED 2 /**< The service has been started */
|
||||
#define SERVICE_STATE_FAILED 3 /**< The service failed to start */
|
||||
#define SERVICE_STATE_STOPPED 4 /**< The service has been stopped */
|
||||
|
||||
/**
|
||||
* Find a service
|
||||
@ -166,7 +185,7 @@ typedef enum count_spec_t
|
||||
*
|
||||
* @return Service or NULL of no service was found
|
||||
*/
|
||||
SERVICE* service_find(const char *name);
|
||||
SERVICE* service_find(const char* name);
|
||||
|
||||
/**
|
||||
* @brief Stop a service
|
||||
@ -175,7 +194,7 @@ SERVICE* service_find(const char *name);
|
||||
*
|
||||
* @return True if service was stopped
|
||||
*/
|
||||
bool serviceStop(SERVICE *service);
|
||||
bool serviceStop(SERVICE* service);
|
||||
|
||||
/**
|
||||
* @brief Restart a stopped service
|
||||
@ -184,7 +203,7 @@ bool serviceStop(SERVICE *service);
|
||||
*
|
||||
* @return True if service was restarted
|
||||
*/
|
||||
bool serviceStart(SERVICE *service);
|
||||
bool serviceStart(SERVICE* service);
|
||||
|
||||
/**
|
||||
* @brief Stop a listener for a service
|
||||
@ -194,7 +213,7 @@ bool serviceStart(SERVICE *service);
|
||||
*
|
||||
* @return True if listener was stopped
|
||||
*/
|
||||
bool serviceStopListener(SERVICE *service, const char *name);
|
||||
bool serviceStopListener(SERVICE* service, const char* name);
|
||||
|
||||
/**
|
||||
* @brief Restart a stopped listener
|
||||
@ -204,19 +223,19 @@ bool serviceStopListener(SERVICE *service, const char *name);
|
||||
*
|
||||
* @return True if listener was restarted
|
||||
*/
|
||||
bool serviceStartListener(SERVICE *service, const char *name);
|
||||
bool serviceStartListener(SERVICE* service, const char* name);
|
||||
|
||||
// TODO: Change binlogrouter to use the functions in config_runtime.h
|
||||
bool serviceAddBackend(SERVICE *service, SERVER *server);
|
||||
bool serviceAddBackend(SERVICE* service, SERVER* server);
|
||||
|
||||
// Used by authenticators
|
||||
void serviceGetUser(SERVICE *service, const char **user, const char **auth);
|
||||
void serviceGetUser(SERVICE* service, const char** user, const char** auth);
|
||||
|
||||
// Used by routers
|
||||
const char* serviceGetWeightingParameter(SERVICE *service);
|
||||
const char* serviceGetWeightingParameter(SERVICE* service);
|
||||
|
||||
// Reload users
|
||||
int service_refresh_users(SERVICE *service);
|
||||
int service_refresh_users(SERVICE* service);
|
||||
|
||||
/**
|
||||
* Diagnostics
|
||||
@ -228,13 +247,13 @@ int service_refresh_users(SERVICE *service);
|
||||
* @param dcb DCB to print to
|
||||
* @param service The service to diagnose
|
||||
*/
|
||||
void service_print_users(DCB *, const SERVICE *);
|
||||
void service_print_users(DCB*, const SERVICE*);
|
||||
|
||||
void dprintAllServices(DCB *dcb);
|
||||
void dprintService(DCB *dcb, SERVICE *service);
|
||||
void dListServices(DCB *dcb);
|
||||
void dListListeners(DCB *dcb);
|
||||
int serviceSessionCountAll(void);
|
||||
void dprintAllServices(DCB* dcb);
|
||||
void dprintService(DCB* dcb, SERVICE* service);
|
||||
void dListServices(DCB* dcb);
|
||||
void dListListeners(DCB* dcb);
|
||||
int serviceSessionCountAll(void);
|
||||
|
||||
/**
|
||||
* Get the capabilities of the servive.
|
||||
@ -244,16 +263,16 @@ int serviceSessionCountAll(void);
|
||||
*
|
||||
* @return The service capabilities.
|
||||
*/
|
||||
static inline uint64_t service_get_capabilities(const SERVICE *service)
|
||||
static inline uint64_t service_get_capabilities(const SERVICE* service)
|
||||
{
|
||||
return service->capabilities;
|
||||
}
|
||||
|
||||
typedef enum service_version_which_t
|
||||
{
|
||||
SERVICE_VERSION_ANY, /*< Any version of the servers of a service. */
|
||||
SERVICE_VERSION_MIN, /*< The minimum version. */
|
||||
SERVICE_VERSION_MAX, /*< The maximum version. */
|
||||
SERVICE_VERSION_ANY, /*< Any version of the servers of a service. */
|
||||
SERVICE_VERSION_MIN, /*< The minimum version. */
|
||||
SERVICE_VERSION_MAX, /*< The maximum version. */
|
||||
} service_version_which_t;
|
||||
|
||||
/**
|
||||
@ -271,6 +290,6 @@ typedef enum service_version_which_t
|
||||
*
|
||||
* @return The version of the service.
|
||||
*/
|
||||
uint64_t service_get_version(const SERVICE *service, service_version_which_t which);
|
||||
uint64_t service_get_version(const SERVICE* service, service_version_which_t which);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file include/maxscale/session.h - The public session interface
|
||||
@ -50,38 +50,71 @@ typedef enum
|
||||
SESSION_STATE_DUMMY /*< dummy session for consistency */
|
||||
} mxs_session_state_t;
|
||||
|
||||
#define STRSESSIONSTATE(s) ((s) == SESSION_STATE_ALLOC ? "SESSION_STATE_ALLOC" : \
|
||||
((s) == SESSION_STATE_READY ? "SESSION_STATE_READY" : \
|
||||
((s) == SESSION_STATE_ROUTER_READY ? "SESSION_STATE_ROUTER_READY" : \
|
||||
((s) == SESSION_STATE_STOPPING ? "SESSION_STATE_STOPPING": \
|
||||
((s) == SESSION_STATE_LISTENER ? "SESSION_STATE_LISTENER" : \
|
||||
((s) == SESSION_STATE_LISTENER_STOPPED ? "SESSION_STATE_LISTENER_STOPPED" : \
|
||||
((s) == SESSION_STATE_TO_BE_FREED ? "SESSION_STATE_TO_BE_FREED" : \
|
||||
((s) == SESSION_STATE_FREE ? "SESSION_STATE_TO_BE_FREE" : \
|
||||
((s) == SESSION_STATE_DUMMY ? "SESSION_STATE_DUMMY" : \
|
||||
"SESSION_STATE_UNKNOWN")))))))))
|
||||
#define STRSESSIONSTATE(s) \
|
||||
((s) == SESSION_STATE_ALLOC ? "SESSION_STATE_ALLOC" \
|
||||
: ((s) == SESSION_STATE_READY ? "SESSION_STATE_READY" \
|
||||
: ((s) \
|
||||
== SESSION_STATE_ROUTER_READY ? \
|
||||
"SESSION_STATE_ROUTER_READY" \
|
||||
: ((s) \
|
||||
== \
|
||||
SESSION_STATE_STOPPING \
|
||||
? \
|
||||
"SESSION_STATE_STOPPING" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
SESSION_STATE_LISTENER \
|
||||
? \
|
||||
"SESSION_STATE_LISTENER" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
SESSION_STATE_LISTENER_STOPPED \
|
||||
? \
|
||||
"SESSION_STATE_LISTENER_STOPPED" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
SESSION_STATE_TO_BE_FREED \
|
||||
? \
|
||||
"SESSION_STATE_TO_BE_FREED" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
SESSION_STATE_FREE \
|
||||
? \
|
||||
"SESSION_STATE_TO_BE_FREE" \
|
||||
: (( \
|
||||
s) \
|
||||
== \
|
||||
SESSION_STATE_DUMMY \
|
||||
? \
|
||||
"SESSION_STATE_DUMMY" \
|
||||
: \
|
||||
"SESSION_STATE_UNKNOWN")))))))))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SESSION_TRX_INACTIVE_BIT = 0x01, /* 0b00001 */
|
||||
SESSION_TRX_ACTIVE_BIT = 0x02, /* 0b00010 */
|
||||
SESSION_TRX_READ_ONLY_BIT = 0x04, /* 0b00100 */
|
||||
SESSION_TRX_READ_WRITE_BIT = 0x08, /* 0b01000 */
|
||||
SESSION_TRX_ENDING_BIT = 0x10, /* 0b10000*/
|
||||
SESSION_TRX_INACTIVE_BIT = 0x01, /* 0b00001 */
|
||||
SESSION_TRX_ACTIVE_BIT = 0x02, /* 0b00010 */
|
||||
SESSION_TRX_READ_ONLY_BIT = 0x04, /* 0b00100 */
|
||||
SESSION_TRX_READ_WRITE_BIT = 0x08, /* 0b01000 */
|
||||
SESSION_TRX_ENDING_BIT = 0x10, /* 0b10000*/
|
||||
} session_trx_state_bit_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/*< There is no on-going transaction. */
|
||||
SESSION_TRX_INACTIVE = SESSION_TRX_INACTIVE_BIT,
|
||||
SESSION_TRX_INACTIVE = SESSION_TRX_INACTIVE_BIT,
|
||||
/*< A transaction is active. */
|
||||
SESSION_TRX_ACTIVE = SESSION_TRX_ACTIVE_BIT,
|
||||
SESSION_TRX_ACTIVE = SESSION_TRX_ACTIVE_BIT,
|
||||
/*< An explicit READ ONLY transaction is active. */
|
||||
SESSION_TRX_READ_ONLY = (SESSION_TRX_ACTIVE_BIT | SESSION_TRX_READ_ONLY_BIT),
|
||||
SESSION_TRX_READ_ONLY = (SESSION_TRX_ACTIVE_BIT | SESSION_TRX_READ_ONLY_BIT),
|
||||
/*< An explicit READ WRITE transaction is active. */
|
||||
SESSION_TRX_READ_WRITE = (SESSION_TRX_ACTIVE_BIT | SESSION_TRX_READ_WRITE_BIT),
|
||||
SESSION_TRX_READ_WRITE = (SESSION_TRX_ACTIVE_BIT | SESSION_TRX_READ_WRITE_BIT),
|
||||
/*< An explicit READ ONLY transaction is ending. */
|
||||
SESSION_TRX_READ_ONLY_ENDING = (SESSION_TRX_ENDING_BIT | SESSION_TRX_READ_ONLY),
|
||||
SESSION_TRX_READ_ONLY_ENDING = (SESSION_TRX_ENDING_BIT | SESSION_TRX_READ_ONLY),
|
||||
/*< An explicit READ WRITE transaction is ending. */
|
||||
SESSION_TRX_READ_WRITE_ENDING = (SESSION_TRX_ENDING_BIT | SESSION_TRX_READ_WRITE),
|
||||
} mxs_session_trx_state_t;
|
||||
@ -98,7 +131,7 @@ typedef enum
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
time_t connect; /**< Time when the session was started */
|
||||
time_t connect; /**< Time when the session was started */
|
||||
} MXS_SESSION_STATS;
|
||||
|
||||
/**
|
||||
@ -109,14 +142,18 @@ struct mxs_filter;
|
||||
struct mxs_filter_session;
|
||||
|
||||
// These are more convenient types
|
||||
typedef int32_t (*DOWNSTREAMFUNC)(struct mxs_filter *instance, struct mxs_filter_session *session, GWBUF *response);
|
||||
typedef int32_t (*UPSTREAMFUNC)(struct mxs_filter *instance, struct mxs_filter_session *session, GWBUF *response);
|
||||
typedef int32_t (* DOWNSTREAMFUNC)(struct mxs_filter* instance,
|
||||
struct mxs_filter_session* session,
|
||||
GWBUF* response);
|
||||
typedef int32_t (* UPSTREAMFUNC)(struct mxs_filter* instance,
|
||||
struct mxs_filter_session* session,
|
||||
GWBUF* response);
|
||||
|
||||
typedef struct mxs_downstream
|
||||
{
|
||||
struct mxs_filter *instance;
|
||||
struct mxs_filter_session *session;
|
||||
DOWNSTREAMFUNC routeQuery;
|
||||
struct mxs_filter* instance;
|
||||
struct mxs_filter_session* session;
|
||||
DOWNSTREAMFUNC routeQuery;
|
||||
} MXS_DOWNSTREAM;
|
||||
|
||||
/**
|
||||
@ -125,9 +162,9 @@ typedef struct mxs_downstream
|
||||
*/
|
||||
typedef struct mxs_upstream
|
||||
{
|
||||
struct mxs_filter *instance;
|
||||
struct mxs_filter_session *session;
|
||||
UPSTREAMFUNC clientReply;
|
||||
struct mxs_filter* instance;
|
||||
struct mxs_filter_session* session;
|
||||
UPSTREAMFUNC clientReply;
|
||||
} MXS_UPSTREAM;
|
||||
|
||||
/* Specific reasons why a session was closed */
|
||||
@ -159,10 +196,10 @@ typedef enum
|
||||
* @return NULL if successful, otherwise a dynamically allocated string
|
||||
* containing an end-user friendly error message.
|
||||
*/
|
||||
typedef char* (*session_variable_handler_t)(void* context,
|
||||
const char* name,
|
||||
const char* value_begin,
|
||||
const char* value_end);
|
||||
typedef char* (* session_variable_handler_t)(void* context,
|
||||
const char* name,
|
||||
const char* value_begin,
|
||||
const char* value_end);
|
||||
|
||||
/**
|
||||
* The session status block
|
||||
@ -176,27 +213,28 @@ typedef char* (*session_variable_handler_t)(void* context,
|
||||
*/
|
||||
typedef struct session
|
||||
{
|
||||
mxs_session_state_t state; /*< Current descriptor state */
|
||||
uint64_t ses_id; /*< Unique session identifier */
|
||||
struct dcb *client_dcb; /*< The client connection */
|
||||
mxs_session_state_t state; /*< Current descriptor state */
|
||||
uint64_t ses_id; /*< Unique session identifier */
|
||||
struct dcb* client_dcb; /*< The client connection */
|
||||
|
||||
struct mxs_router_session *router_session; /*< The router instance data */
|
||||
MXS_SESSION_STATS stats; /*< Session statistics */
|
||||
struct service *service; /*< The service this session is using */
|
||||
MXS_DOWNSTREAM head; /*< Head of the filter chain */
|
||||
MXS_UPSTREAM tail; /*< The tail of the filter chain */
|
||||
int refcount; /*< Reference count on the session */
|
||||
mxs_session_trx_state_t trx_state; /*< The current transaction state. */
|
||||
bool autocommit; /*< Whether autocommit is on. */
|
||||
intptr_t client_protocol_data; /*< Owned and managed by the client protocol. */
|
||||
bool qualifies_for_pooling; /**< Whether this session qualifies for the connection pool */
|
||||
struct mxs_router_session* router_session; /*< The router instance data */
|
||||
MXS_SESSION_STATS stats; /*< Session statistics */
|
||||
struct service* service; /*< The service this session is using */
|
||||
MXS_DOWNSTREAM head; /*< Head of the filter chain */
|
||||
MXS_UPSTREAM tail; /*< The tail of the filter chain */
|
||||
int refcount; /*< Reference count on the session */
|
||||
mxs_session_trx_state_t trx_state; /*< The current transaction state. */
|
||||
bool autocommit; /*< Whether autocommit is on. */
|
||||
intptr_t client_protocol_data; /*< Owned and managed by the client protocol. */
|
||||
bool qualifies_for_pooling; /**< Whether this session qualifies for the connection
|
||||
* pool */
|
||||
struct
|
||||
{
|
||||
MXS_UPSTREAM up; /*< Upward component to receive buffer. */
|
||||
GWBUF* buffer; /*< Buffer to deliver to up. */
|
||||
} response; /*< Shortcircuited response */
|
||||
session_close_t close_reason; /*< Reason why the session was closed */
|
||||
bool load_active; /*< Data streaming state (for LOAD DATA LOCAL INFILE) */
|
||||
MXS_UPSTREAM up; /*< Upward component to receive buffer. */
|
||||
GWBUF* buffer; /*< Buffer to deliver to up. */
|
||||
} response; /*< Shortcircuited response */
|
||||
session_close_t close_reason; /*< Reason why the session was closed */
|
||||
bool load_active; /*< Data streaming state (for LOAD DATA LOCAL INFILE) */
|
||||
} MXS_SESSION;
|
||||
|
||||
/**
|
||||
@ -209,7 +247,7 @@ typedef struct session
|
||||
* @param up The filter that should receive the response.
|
||||
* @param buffer The response.
|
||||
*/
|
||||
void session_set_response(MXS_SESSION *session, const MXS_UPSTREAM *up, GWBUF *buffer);
|
||||
void session_set_response(MXS_SESSION* session, const MXS_UPSTREAM* up, GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* Function to be used by protocol module for routing incoming data
|
||||
@ -220,7 +258,7 @@ void session_set_response(MXS_SESSION *session, const MXS_UPSTREAM *up, GWBUF *b
|
||||
*
|
||||
* @return True, if the routing should continue, false otherwise.
|
||||
*/
|
||||
bool session_route_query(MXS_SESSION *session, GWBUF *buffer);
|
||||
bool session_route_query(MXS_SESSION* session, GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* Function to be used by the router module to route the replies to
|
||||
@ -231,7 +269,7 @@ bool session_route_query(MXS_SESSION *session, GWBUF *buffer);
|
||||
*
|
||||
* @return True, if the routing should continue, false otherwise.
|
||||
*/
|
||||
bool session_route_reply(MXS_SESSION *session, GWBUF *buffer);
|
||||
bool session_route_reply(MXS_SESSION* session, GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* A convenience macro that can be used by the protocol modules to route
|
||||
@ -258,7 +296,7 @@ bool session_route_reply(MXS_SESSION *session, GWBUF *buffer);
|
||||
* @param client_dcb The client side DCB
|
||||
* @return The newly created session or NULL if an error occurred
|
||||
*/
|
||||
MXS_SESSION *session_alloc(struct service *, struct dcb *);
|
||||
MXS_SESSION* session_alloc(struct service*, struct dcb*);
|
||||
|
||||
/**
|
||||
* A version of session_alloc() which takes the session id number as parameter.
|
||||
@ -269,17 +307,17 @@ MXS_SESSION *session_alloc(struct service *, struct dcb *);
|
||||
* @param id Id for the new session.
|
||||
* @return The newly created session or NULL if an error occurred
|
||||
*/
|
||||
MXS_SESSION *session_alloc_with_id(struct service *, struct dcb *, uint64_t);
|
||||
MXS_SESSION* session_alloc_with_id(struct service*, struct dcb*, uint64_t);
|
||||
|
||||
MXS_SESSION *session_set_dummy(struct dcb *);
|
||||
MXS_SESSION* session_set_dummy(struct dcb*);
|
||||
|
||||
static inline bool session_is_dummy(MXS_SESSION* session)
|
||||
{
|
||||
return session->state == SESSION_STATE_DUMMY;
|
||||
}
|
||||
|
||||
const char *session_get_remote(const MXS_SESSION *);
|
||||
const char *session_get_user(const MXS_SESSION *);
|
||||
const char* session_get_remote(const MXS_SESSION*);
|
||||
const char* session_get_user(const MXS_SESSION*);
|
||||
|
||||
/**
|
||||
* Convert transaction state to string representation.
|
||||
@ -450,7 +488,7 @@ uint64_t session_get_next_id();
|
||||
*
|
||||
* @param session The session to close
|
||||
*/
|
||||
void session_close(MXS_SESSION *session);
|
||||
void session_close(MXS_SESSION* session);
|
||||
|
||||
/**
|
||||
* @brief Release a session reference
|
||||
@ -459,7 +497,7 @@ void session_close(MXS_SESSION *session);
|
||||
*
|
||||
* @param session Session reference to release
|
||||
*/
|
||||
void session_put_ref(MXS_SESSION *session);
|
||||
void session_put_ref(MXS_SESSION* session);
|
||||
|
||||
/**
|
||||
* @brief Convert a session to JSON
|
||||
@ -469,7 +507,7 @@ void session_put_ref(MXS_SESSION *session);
|
||||
*
|
||||
* @return New JSON object or NULL on error
|
||||
*/
|
||||
json_t* session_to_json(const MXS_SESSION *session, const char* host);
|
||||
json_t* session_to_json(const MXS_SESSION* session, const char* host);
|
||||
|
||||
/**
|
||||
* @brief Convert all sessions to JSON
|
||||
@ -531,10 +569,10 @@ uint64_t session_get_current_id();
|
||||
*
|
||||
* @return True, if the variable could be added, false otherwise.
|
||||
*/
|
||||
bool session_add_variable(MXS_SESSION* session,
|
||||
const char* name,
|
||||
bool session_add_variable(MXS_SESSION* session,
|
||||
const char* name,
|
||||
session_variable_handler_t handler,
|
||||
void* context);
|
||||
void* context);
|
||||
|
||||
/**
|
||||
* @brief Remove MaxScale specific user variable from the session.
|
||||
@ -553,7 +591,7 @@ bool session_add_variable(MXS_SESSION* session,
|
||||
*/
|
||||
bool session_remove_variable(MXS_SESSION* session,
|
||||
const char* name,
|
||||
void** context);
|
||||
void** context);
|
||||
/**
|
||||
* @brief Set value of maxscale session variable.
|
||||
*
|
||||
@ -570,10 +608,10 @@ bool session_remove_variable(MXS_SESSION* session,
|
||||
* incoming statements.
|
||||
*/
|
||||
char* session_set_variable_value(MXS_SESSION* session,
|
||||
const char* name_begin,
|
||||
const char* name_end,
|
||||
const char* value_begin,
|
||||
const char* value_end);
|
||||
const char* name_begin,
|
||||
const char* name_end,
|
||||
const char* value_begin,
|
||||
const char* value_end);
|
||||
|
||||
/**
|
||||
* @brief Specify how many statements each session should retain for
|
||||
|
||||
@ -22,7 +22,7 @@ namespace maxscale
|
||||
template<>
|
||||
struct RegistryTraits<MXS_SESSION>
|
||||
{
|
||||
typedef uint64_t id_type;
|
||||
typedef uint64_t id_type;
|
||||
typedef MXS_SESSION* entry_type;
|
||||
|
||||
static id_type get_id(entry_type entry)
|
||||
@ -34,5 +34,4 @@ struct RegistryTraits<MXS_SESSION>
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -25,7 +25,7 @@ namespace maxscale
|
||||
|
||||
class SessionCommand;
|
||||
typedef std::shared_ptr<SessionCommand> SSessionCommand;
|
||||
typedef std::list<SSessionCommand> SessionCommandList;
|
||||
typedef std::list<SSessionCommand> SessionCommandList;
|
||||
|
||||
class SessionCommand
|
||||
{
|
||||
@ -71,7 +71,7 @@ public:
|
||||
* of @c buffer is transferred to this object.
|
||||
* @param id A unique position identifier used to track replies
|
||||
*/
|
||||
SessionCommand(GWBUF *buffer, uint64_t id);
|
||||
SessionCommand(GWBUF* buffer, uint64_t id);
|
||||
|
||||
~SessionCommand();
|
||||
|
||||
@ -101,20 +101,19 @@ public:
|
||||
void mark_as_duplicate(const SessionCommand& rhs);
|
||||
|
||||
private:
|
||||
mxs::Buffer m_buffer; /**< The buffer containing the command */
|
||||
uint8_t m_command; /**< The command being executed */
|
||||
uint64_t m_pos; /**< Unique position identifier */
|
||||
bool m_reply_sent; /**< Whether the session command reply has been sent */
|
||||
mxs::Buffer m_buffer; /**< The buffer containing the command */
|
||||
uint8_t m_command; /**< The command being executed */
|
||||
uint64_t m_pos; /**< Unique position identifier */
|
||||
bool m_reply_sent; /**< Whether the session command reply has been sent */
|
||||
};
|
||||
|
||||
inline bool operator ==(const SessionCommand& lhs, const SessionCommand& rhs)
|
||||
inline bool operator==(const SessionCommand& lhs, const SessionCommand& rhs)
|
||||
{
|
||||
return lhs.eq(rhs);
|
||||
}
|
||||
|
||||
inline bool operator !=(const SessionCommand& lhs, const SessionCommand& rhs)
|
||||
inline bool operator!=(const SessionCommand& lhs, const SessionCommand& rhs)
|
||||
{
|
||||
return !lhs.eq(rhs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file spinlock.h
|
||||
@ -42,22 +42,22 @@ MXS_BEGIN_DECLS
|
||||
*/
|
||||
typedef struct spinlock
|
||||
{
|
||||
int lock; /*< Is the lock held? */
|
||||
int lock; /*< Is the lock held? */
|
||||
#if SPINLOCK_PROFILE
|
||||
uint64_t spins; /*< Number of spins on this lock */
|
||||
uint64_t maxspins; /*< Max no of spins to acquire lock */
|
||||
uint64_t acquired; /*< No. of times lock was acquired */
|
||||
uint64_t waiting; /*< No. of threads acquiring this lock */
|
||||
uint64_t max_waiting; /*< Max no of threads waiting for lock */
|
||||
uint64_t contended; /*< No. of times acquire was contended */
|
||||
THREAD owner; /*< Last owner of this lock */
|
||||
uint64_t spins; /*< Number of spins on this lock */
|
||||
uint64_t maxspins; /*< Max no of spins to acquire lock */
|
||||
uint64_t acquired; /*< No. of times lock was acquired */
|
||||
uint64_t waiting; /*< No. of threads acquiring this lock */
|
||||
uint64_t max_waiting; /*< Max no of threads waiting for lock */
|
||||
uint64_t contended; /*< No. of times acquire was contended */
|
||||
THREAD owner; /*< Last owner of this lock */
|
||||
#endif
|
||||
} SPINLOCK;
|
||||
|
||||
#if SPINLOCK_PROFILE
|
||||
#define SPINLOCK_INIT { 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
#define SPINLOCK_INIT {0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#else
|
||||
#define SPINLOCK_INIT { 0 }
|
||||
#define SPINLOCK_INIT {0}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -72,14 +72,14 @@ typedef struct spinlock
|
||||
*
|
||||
* @param lock The spinlock to initialise.
|
||||
*/
|
||||
extern void spinlock_init(SPINLOCK *lock);
|
||||
extern void spinlock_init(SPINLOCK* lock);
|
||||
|
||||
/**
|
||||
* Acquire a spinlock.
|
||||
*
|
||||
* @param lock The spinlock to acquire
|
||||
*/
|
||||
extern void spinlock_acquire(const SPINLOCK *lock);
|
||||
extern void spinlock_acquire(const SPINLOCK* lock);
|
||||
|
||||
/**
|
||||
* Acquire a spinlock if it is not already locked.
|
||||
@ -87,14 +87,14 @@ extern void spinlock_acquire(const SPINLOCK *lock);
|
||||
* @param lock The spinlock to acquire
|
||||
* @return True if the spinlock was acquired, otherwise false
|
||||
*/
|
||||
extern bool spinlock_acquire_nowait(const SPINLOCK *lock);
|
||||
extern bool spinlock_acquire_nowait(const SPINLOCK* lock);
|
||||
|
||||
/*
|
||||
* Release a spinlock.
|
||||
*
|
||||
* @param lock The spinlock to release
|
||||
*/
|
||||
extern void spinlock_release(const SPINLOCK *lock);
|
||||
extern void spinlock_release(const SPINLOCK* lock);
|
||||
|
||||
/**
|
||||
* Report statistics on a spinlock. This only has an effect if the
|
||||
@ -109,6 +109,6 @@ extern void spinlock_release(const SPINLOCK *lock);
|
||||
* @param reporter The callback function to pass the statistics to
|
||||
* @param hdl A handle that is passed to the reporter function
|
||||
*/
|
||||
extern void spinlock_stats(const SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl);
|
||||
extern void spinlock_stats(const SPINLOCK* lock, void (* reporter)(void*, char*, int), void* hdl);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxscale/spinlock.h>
|
||||
@ -60,8 +60,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SpinLock(const SpinLock&) /* = delete */;
|
||||
SpinLock& operator = (const SpinLock&) /* = delete */;
|
||||
SpinLock(const SpinLock&) /* = delete */;
|
||||
SpinLock& operator=(const SpinLock&) /* = delete */;
|
||||
|
||||
private:
|
||||
mutable SPINLOCK m_lock;
|
||||
@ -112,10 +112,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SpinLockGuard(const SpinLockGuard&) /* = delete */;
|
||||
SpinLockGuard& operator = (const SpinLockGuard&) /* = delete */;
|
||||
SpinLockGuard(const SpinLockGuard&) /* = delete */;
|
||||
SpinLockGuard& operator=(const SpinLockGuard&) /* = delete */;
|
||||
|
||||
const SPINLOCK& m_lock;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file sqlite3.h
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ssl.h
|
||||
@ -47,9 +47,9 @@ typedef enum ssl_method_type
|
||||
/**
|
||||
* Return codes for SSL authentication checks
|
||||
*/
|
||||
#define SSL_AUTH_CHECKS_OK 0
|
||||
#define SSL_AUTH_CHECKS_OK 0
|
||||
#define SSL_ERROR_CLIENT_NOT_SSL 1
|
||||
#define SSL_ERROR_ACCEPT_FAILED 2
|
||||
#define SSL_ERROR_ACCEPT_FAILED 2
|
||||
|
||||
/**
|
||||
* The ssl_listener structure is used to aggregate the SSL configuration items
|
||||
@ -57,26 +57,28 @@ typedef enum ssl_method_type
|
||||
*/
|
||||
typedef struct ssl_listener
|
||||
{
|
||||
SSL_CTX *ctx;
|
||||
SSL_METHOD *method; /*< SSLv3 or TLS1.0/1.1/1.2 methods
|
||||
* see: https://www.openssl.org/docs/ssl/SSL_CTX_new.html */
|
||||
int ssl_cert_verify_depth; /*< SSL certificate verification depth */
|
||||
ssl_method_type_t ssl_method_type; /*< Which of the SSLv3 or TLS1.0/1.1/1.2 methods to use */
|
||||
char *ssl_cert; /*< SSL certificate */
|
||||
char *ssl_key; /*< SSL private key */
|
||||
char *ssl_ca_cert; /*< SSL CA certificate */
|
||||
bool ssl_init_done; /*< If SSL has already been initialized for this service */
|
||||
bool ssl_verify_peer_certificate; /*< Enable peer certificate verification */
|
||||
SSL_CTX* ctx;
|
||||
SSL_METHOD* method; /*< SSLv3 or TLS1.0/1.1/1.2 methods
|
||||
* see: https://www.openssl.org/docs/ssl/SSL_CTX_new.html
|
||||
**/
|
||||
int ssl_cert_verify_depth; /*< SSL certificate verification depth */
|
||||
ssl_method_type_t ssl_method_type; /*< Which of the SSLv3 or TLS1.0/1.1/1.2 methods to use */
|
||||
char* ssl_cert; /*< SSL certificate */
|
||||
char* ssl_key; /*< SSL private key */
|
||||
char* ssl_ca_cert; /*< SSL CA certificate */
|
||||
bool ssl_init_done; /*< If SSL has already been initialized for this service
|
||||
* */
|
||||
bool ssl_verify_peer_certificate; /*< Enable peer certificate verification */
|
||||
struct ssl_listener
|
||||
*next; /*< Next SSL configuration, currently used to store obsolete configurations */
|
||||
* next; /*< Next SSL configuration, currently used to store obsolete configurations */
|
||||
} SSL_LISTENER;
|
||||
|
||||
int ssl_authenticate_client(struct dcb *dcb, bool is_capable);
|
||||
bool ssl_is_connection_healthy(struct dcb *dcb);
|
||||
bool ssl_check_data_to_process(struct dcb *dcb);
|
||||
bool ssl_required_by_dcb(struct dcb *dcb);
|
||||
bool ssl_required_but_not_negotiated(struct dcb *dcb);
|
||||
const char* ssl_method_type_to_string(ssl_method_type_t method_type);
|
||||
int ssl_authenticate_client(struct dcb* dcb, bool is_capable);
|
||||
bool ssl_is_connection_healthy(struct dcb* dcb);
|
||||
bool ssl_check_data_to_process(struct dcb* dcb);
|
||||
bool ssl_required_by_dcb(struct dcb* dcb);
|
||||
bool ssl_required_but_not_negotiated(struct dcb* dcb);
|
||||
const char* ssl_method_type_to_string(ssl_method_type_t method_type);
|
||||
ssl_method_type_t string_to_ssl_method_type(const char* str);
|
||||
|
||||
/**
|
||||
@ -89,7 +91,7 @@ ssl_method_type_t string_to_ssl_method_type(const char* str);
|
||||
* if ssl authentication is in progress and should be retried, MXS_AUTH_SSL_COMPLETE
|
||||
* if ssl authentication is complete or not required.
|
||||
*/
|
||||
int ssl_authenticate_check_status(struct dcb *dcb);
|
||||
int ssl_authenticate_check_status(struct dcb* dcb);
|
||||
|
||||
// TODO: Move this to an internal ssl.h header
|
||||
void write_ssl_config(int fd, SSL_LISTENER* ssl);
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file statistics.h - Lock-free statistics gathering
|
||||
@ -26,10 +26,10 @@ typedef void* ts_stats_t;
|
||||
/** Enum values for ts_stats_get */
|
||||
enum ts_stats_type
|
||||
{
|
||||
TS_STATS_MAX, /**< Maximum value */
|
||||
TS_STATS_MIX, /**< Minimum value */
|
||||
TS_STATS_SUM, /**< Sum of all value */
|
||||
TS_STATS_AVG /**< Average of all values */
|
||||
TS_STATS_MAX, /**< Maximum value */
|
||||
TS_STATS_MIX, /**< Minimum value */
|
||||
TS_STATS_SUM, /**< Sum of all value */
|
||||
TS_STATS_AVG /**< Average of all values */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file users.h The functions to manipulate a set of administrative users
|
||||
@ -29,8 +29,8 @@ MXS_BEGIN_DECLS
|
||||
enum user_account_type
|
||||
{
|
||||
USER_ACCOUNT_UNKNOWN,
|
||||
USER_ACCOUNT_BASIC, /**< Allows read-only access */
|
||||
USER_ACCOUNT_ADMIN /**< Allows complete access */
|
||||
USER_ACCOUNT_BASIC, /**< Allows read-only access */
|
||||
USER_ACCOUNT_ADMIN /**< Allows complete access */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -64,7 +64,7 @@ void users_free(USERS* users);
|
||||
*
|
||||
* @return True if user was added
|
||||
*/
|
||||
bool users_add(USERS *users, const char *user, const char *password, enum user_account_type type);
|
||||
bool users_add(USERS* users, const char* user, const char* password, enum user_account_type type);
|
||||
|
||||
/**
|
||||
* Delete a user from the user table.
|
||||
@ -74,7 +74,7 @@ bool users_add(USERS *users, const char *user, const char *password, enum user_a
|
||||
*
|
||||
* @return True if user was deleted
|
||||
*/
|
||||
bool users_delete(USERS *users, const char *user);
|
||||
bool users_delete(USERS* users, const char* user);
|
||||
|
||||
/**
|
||||
* Authenticate a user
|
||||
@ -125,7 +125,7 @@ int users_admin_count(USERS* users);
|
||||
*
|
||||
* @return JSON form of the users that can be used for serialization
|
||||
*/
|
||||
json_t* users_to_json(USERS *users);
|
||||
json_t* users_to_json(USERS* users);
|
||||
|
||||
/**
|
||||
* Load users from JSON
|
||||
@ -144,7 +144,7 @@ USERS* users_from_json(json_t* json);
|
||||
* @param port Listener configuration
|
||||
* @return Always AUTH_LOADUSERS_OK
|
||||
*/
|
||||
int users_default_loadusers(SERV_LISTENER *port);
|
||||
int users_default_loadusers(SERV_LISTENER* port);
|
||||
|
||||
/**
|
||||
* @brief Default authenticator diagnostic function
|
||||
@ -152,14 +152,14 @@ int users_default_loadusers(SERV_LISTENER *port);
|
||||
* @param dcb DCB where data is printed
|
||||
* @param port Port whose data is to be printed
|
||||
*/
|
||||
void users_default_diagnostic(DCB *dcb, SERV_LISTENER *port);
|
||||
void users_default_diagnostic(DCB* dcb, SERV_LISTENER* port);
|
||||
|
||||
/**
|
||||
* @brief Default authenticator diagnostic function
|
||||
*
|
||||
* @param port Port whose data is to be printed
|
||||
*/
|
||||
json_t* users_default_diagnostic_json(const SERV_LISTENER *port);
|
||||
json_t* users_default_diagnostic_json(const SERV_LISTENER* port);
|
||||
|
||||
/**
|
||||
* Print users to a DCB
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file utils.h Utility functions headers
|
||||
@ -26,9 +26,9 @@
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define CALCLEN(i) ((size_t)(floor(log10(abs((int64_t)i))) + 1))
|
||||
#define UINTLEN(i) (i<10 ? 1 : (i<100 ? 2 : (i<1000 ? 3 : CALCLEN(i))))
|
||||
#define UINTLEN(i) (i < 10 ? 1 : (i < 100 ? 2 : (i < 1000 ? 3 : CALCLEN(i))))
|
||||
|
||||
#define MXS_ARRAY_NELEMS(array) ((size_t)(sizeof(array)/sizeof(array[0])))
|
||||
#define MXS_ARRAY_NELEMS(array) ((size_t)(sizeof(array) / sizeof(array[0])))
|
||||
|
||||
/** Macro for safe pointer arithmetic on void pointers
|
||||
* @param a The void pointer
|
||||
@ -39,11 +39,11 @@ MXS_BEGIN_DECLS
|
||||
/** The type of the socket */
|
||||
enum mxs_socket_type
|
||||
{
|
||||
MXS_SOCKET_LISTENER, /**< */
|
||||
MXS_SOCKET_LISTENER, /**< */
|
||||
MXS_SOCKET_NETWORK,
|
||||
};
|
||||
|
||||
bool utils_init(); /*< Call this first before using any other function */
|
||||
bool utils_init(); /*< Call this first before using any other function */
|
||||
void utils_end();
|
||||
|
||||
/**
|
||||
@ -67,8 +67,10 @@ void utils_end();
|
||||
*
|
||||
* @return The opened socket or -1 on failure
|
||||
*/
|
||||
int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr,
|
||||
const char *host, uint16_t port);
|
||||
int open_network_socket(enum mxs_socket_type type,
|
||||
struct sockaddr_storage* addr,
|
||||
const char* host,
|
||||
uint16_t port);
|
||||
|
||||
/**
|
||||
* @brief Create a UNIX domain socket
|
||||
@ -84,21 +86,22 @@ int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr
|
||||
*
|
||||
* @return The opened socket or -1 on failure
|
||||
*/
|
||||
int open_unix_socket(enum mxs_socket_type type, struct sockaddr_un *addr,
|
||||
const char *path);
|
||||
int open_unix_socket(enum mxs_socket_type type,
|
||||
struct sockaddr_un* addr,
|
||||
const char* path);
|
||||
|
||||
int setnonblocking(int fd);
|
||||
int setblocking(int fd);
|
||||
char *gw_strend(register const char *s);
|
||||
int setnonblocking(int fd);
|
||||
int setblocking(int fd);
|
||||
char* gw_strend(register const char* s);
|
||||
static char gw_randomchar();
|
||||
int gw_generate_random_str(char *output, int len);
|
||||
int gw_hex2bin(uint8_t *out, const char *in, unsigned int len);
|
||||
char *gw_bin2hex(char *out, const uint8_t *in, unsigned int len);
|
||||
void gw_str_xor(uint8_t *output, const uint8_t *input1, const uint8_t *input2, unsigned int len);
|
||||
void gw_sha1_str(const uint8_t *in, int in_len, uint8_t *out);
|
||||
void gw_sha1_2_str(const uint8_t *in, int in_len, const uint8_t *in2, int in2_len, uint8_t *out);
|
||||
int gw_getsockerrno(int fd);
|
||||
char *create_hex_sha1_sha1_passwd(char *passwd);
|
||||
int gw_generate_random_str(char* output, int len);
|
||||
int gw_hex2bin(uint8_t* out, const char* in, unsigned int len);
|
||||
char* gw_bin2hex(char* out, const uint8_t* in, unsigned int len);
|
||||
void gw_str_xor(uint8_t* output, const uint8_t* input1, const uint8_t* input2, unsigned int len);
|
||||
void gw_sha1_str(const uint8_t* in, int in_len, uint8_t* out);
|
||||
void gw_sha1_2_str(const uint8_t* in, int in_len, const uint8_t* in2, int in2_len, uint8_t* out);
|
||||
int gw_getsockerrno(int fd);
|
||||
char* create_hex_sha1_sha1_passwd(char* passwd);
|
||||
|
||||
/**
|
||||
* Trim leading whitespace from a string.
|
||||
@ -133,26 +136,30 @@ char* trim_trailing(char* str);
|
||||
* the returned pointer is always the same the one given as
|
||||
* argument.
|
||||
*/
|
||||
char* trim(char *str);
|
||||
char* trim(char* str);
|
||||
|
||||
void replace_whitespace(char* str);
|
||||
void replace_whitespace(char* str);
|
||||
char* squeeze_whitespace(char* str);
|
||||
bool strip_escape_chars(char*);
|
||||
bool strip_escape_chars(char*);
|
||||
|
||||
bool is_valid_posix_path(char* path);
|
||||
|
||||
char* remove_mysql_comments(const char** src, const size_t* srcsize, char** dest,
|
||||
char* remove_mysql_comments(const char** src,
|
||||
const size_t* srcsize,
|
||||
char** dest,
|
||||
size_t* destsize);
|
||||
char* replace_values(const char** src, const size_t* srcsize, char** dest,
|
||||
char* replace_values(const char** src,
|
||||
const size_t* srcsize,
|
||||
char** dest,
|
||||
size_t* destsize);
|
||||
char* replace_literal(char* haystack,
|
||||
const char* needle,
|
||||
const char* replacement);
|
||||
char* replace_quoted(const char** src, const size_t* srcsize, char** dest, size_t* destsize);
|
||||
|
||||
bool clean_up_pathname(char *path);
|
||||
bool clean_up_pathname(char* path);
|
||||
|
||||
bool mxs_mkdir_all(const char *path, int mask);
|
||||
bool mxs_mkdir_all(const char* path, int mask);
|
||||
|
||||
/**
|
||||
* Return the number of processors
|
||||
@ -195,8 +202,8 @@ static inline uint8_t* mxs_set_byte4(uint8_t* ptr, uint32_t value)
|
||||
*/
|
||||
static inline uint32_t mxs_get_byte4(const uint8_t* ptr)
|
||||
{
|
||||
return ((uint32_t) ptr[0]) | ((uint32_t) ptr[1] << 8) |
|
||||
((uint32_t) ptr[2] << 16) | ((uint32_t) ptr[3] << 24);
|
||||
return ((uint32_t) ptr[0]) | ((uint32_t) ptr[1] << 8)
|
||||
| ((uint32_t) ptr[2] << 16) | ((uint32_t) ptr[3] << 24);
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
|
||||
@ -39,10 +39,12 @@ namespace maxscale
|
||||
*
|
||||
* @param s The string to be trimmed.
|
||||
*/
|
||||
inline void ltrim(std::string &s)
|
||||
inline void ltrim(std::string& s)
|
||||
{
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
s.erase(s.begin(),
|
||||
std::find_if(s.begin(),
|
||||
s.end(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,10 +52,12 @@ inline void ltrim(std::string &s)
|
||||
*
|
||||
* @param s The string to be trimmed.
|
||||
*/
|
||||
inline void rtrim(std::string &s)
|
||||
inline void rtrim(std::string& s)
|
||||
{
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
||||
s.erase(std::find_if(s.rbegin(),
|
||||
s.rend(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
|
||||
s.end());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +65,7 @@ inline void rtrim(std::string &s)
|
||||
*
|
||||
* @param s The string to be trimmed.
|
||||
*/
|
||||
inline void trim(std::string &s)
|
||||
inline void trim(std::string& s)
|
||||
{
|
||||
ltrim(s);
|
||||
rtrim(s);
|
||||
@ -270,12 +274,11 @@ public:
|
||||
|
||||
private:
|
||||
Closer(const Closer&);
|
||||
Closer& operator = (const Closer&);
|
||||
Closer& operator=(const Closer&);
|
||||
|
||||
private:
|
||||
T m_resource;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -309,12 +312,13 @@ struct CloserTraits<FILE*>
|
||||
template<typename EntryType>
|
||||
struct RegistryTraits
|
||||
{
|
||||
typedef int id_type;
|
||||
typedef int id_type;
|
||||
typedef EntryType* entry_type;
|
||||
|
||||
static id_type get_id(entry_type entry)
|
||||
{
|
||||
static_assert(sizeof(EntryType) != sizeof(EntryType), "get_id() and the"
|
||||
static_assert(sizeof(EntryType) != sizeof(EntryType),
|
||||
"get_id() and the"
|
||||
" surrounding struct must be specialized for every EntryType!");
|
||||
return 0;
|
||||
}
|
||||
@ -331,13 +335,13 @@ struct RegistryTraits
|
||||
* underlying container implements. When instantiating with a new EntryType, the
|
||||
* traits-class RegistryTraits should be specialized for the new type as well.
|
||||
*/
|
||||
template <typename EntryType>
|
||||
template<typename EntryType>
|
||||
class Registry
|
||||
{
|
||||
Registry(const Registry&);
|
||||
Registry& operator = (const Registry&);
|
||||
Registry& operator=(const Registry&);
|
||||
public:
|
||||
typedef typename RegistryTraits<EntryType>::id_type id_type;
|
||||
typedef typename RegistryTraits<EntryType>::id_type id_type;
|
||||
typedef typename RegistryTraits<EntryType>::entry_type entry_type;
|
||||
|
||||
Registry()
|
||||
@ -406,7 +410,9 @@ template<typename T>
|
||||
class EqualPointees : public std::unary_function<T, bool>
|
||||
{
|
||||
public:
|
||||
EqualPointees(const T& lhs) : m_ppLhs(&lhs) {}
|
||||
EqualPointees(const T& lhs) : m_ppLhs(&lhs)
|
||||
{
|
||||
}
|
||||
bool operator()(const T& pRhs)
|
||||
{
|
||||
return **m_ppLhs == *pRhs;
|
||||
@ -430,12 +436,12 @@ EqualPointees<T> equal_pointees(const T& t)
|
||||
*/
|
||||
std::string to_hex(uint8_t value);
|
||||
|
||||
template <typename T, typename V>
|
||||
template<typename T, typename V>
|
||||
struct hex_iterator
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
struct hex_iterator<T, uint8_t>
|
||||
{
|
||||
std::string operator()(T begin, T end)
|
||||
@ -457,10 +463,10 @@ struct hex_iterator<T, uint8_t>
|
||||
*
|
||||
* @return Hexadecimal string representation of the data
|
||||
*/
|
||||
template <typename Iter>
|
||||
template<typename Iter>
|
||||
std::string to_hex(Iter begin, Iter end)
|
||||
{
|
||||
return hex_iterator<Iter, typename std::iterator_traits<Iter>::value_type > ()(begin, end);
|
||||
return hex_iterator<Iter, typename std::iterator_traits<Iter>::value_type>()(begin, end);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -470,7 +476,9 @@ class Checksum
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~Checksum() {}
|
||||
virtual ~Checksum()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the checksum calculation
|
||||
@ -509,7 +517,7 @@ public:
|
||||
/**
|
||||
* A SHA1 checksum
|
||||
*/
|
||||
class SHA1Checksum: public Checksum
|
||||
class SHA1Checksum : public Checksum
|
||||
{
|
||||
public:
|
||||
|
||||
@ -518,7 +526,7 @@ public:
|
||||
SHA1Checksum()
|
||||
{
|
||||
SHA1_Init(&m_ctx);
|
||||
m_sum.fill(0); // CentOS 6 doesn't like aggregate initialization...
|
||||
m_sum.fill(0); // CentOS 6 doesn't like aggregate initialization...
|
||||
}
|
||||
|
||||
void update(GWBUF* buffer)
|
||||
@ -552,16 +560,16 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
SHA_CTX m_ctx; /**< SHA1 context */
|
||||
Sum m_sum; /**< Final checksum */
|
||||
SHA_CTX m_ctx; /**< SHA1 context */
|
||||
Sum m_sum; /**< Final checksum */
|
||||
};
|
||||
|
||||
static inline bool operator ==(const SHA1Checksum& lhs, const SHA1Checksum& rhs)
|
||||
static inline bool operator==(const SHA1Checksum& lhs, const SHA1Checksum& rhs)
|
||||
{
|
||||
return lhs.eq(rhs);
|
||||
}
|
||||
|
||||
static inline bool operator !=(const SHA1Checksum& lhs, const SHA1Checksum& rhs)
|
||||
static inline bool operator!=(const SHA1Checksum& lhs, const SHA1Checksum& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -569,7 +577,7 @@ static inline bool operator !=(const SHA1Checksum& lhs, const SHA1Checksum& rhs)
|
||||
/**
|
||||
* A CRC32 checksum
|
||||
*/
|
||||
class CRC32Checksum: public Checksum
|
||||
class CRC32Checksum : public Checksum
|
||||
{
|
||||
public:
|
||||
|
||||
@ -612,16 +620,16 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
uint32_t m_ctx; /**< Ongoing checksum value */
|
||||
uint32_t m_sum; /**< Final checksum */
|
||||
uint32_t m_ctx; /**< Ongoing checksum value */
|
||||
uint32_t m_sum; /**< Final checksum */
|
||||
};
|
||||
|
||||
static inline bool operator ==(const CRC32Checksum& lhs, const CRC32Checksum& rhs)
|
||||
static inline bool operator==(const CRC32Checksum& lhs, const CRC32Checksum& rhs)
|
||||
{
|
||||
return lhs.eq(rhs);
|
||||
}
|
||||
|
||||
static inline bool operator !=(const CRC32Checksum& lhs, const CRC32Checksum& rhs)
|
||||
static inline bool operator!=(const CRC32Checksum& lhs, const CRC32Checksum& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -652,10 +660,10 @@ namespace http
|
||||
|
||||
struct Result
|
||||
{
|
||||
int code; // HTTP response code
|
||||
std::string raw_body; // Raw response body
|
||||
std::unique_ptr<json_t> body; // JSON form of the body if it was valid JSON
|
||||
std::unordered_map<std::string, std::string> headers; // Headers attached to the response
|
||||
int code; // HTTP response code
|
||||
std::string raw_body; // Raw response body
|
||||
std::unique_ptr<json_t> body; // JSON form of the body if it was valid JSON
|
||||
std::unordered_map<std::string, std::string> headers; // Headers attached to the response
|
||||
};
|
||||
|
||||
/**
|
||||
@ -668,7 +676,5 @@ struct Result
|
||||
* @return A Result
|
||||
*/
|
||||
Result get(const std::string& url, const std::string& user = "", const std::string& password = "");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user