Cleanup server.hh

Simplify type definitions.
This commit is contained in:
Esa Korhonen 2018-12-04 16:53:37 +02:00
parent 7ca421fe5f
commit f2fcf79fb2
10 changed files with 37 additions and 43 deletions

View File

@ -44,7 +44,7 @@ typedef enum authenticator_capability
#define AUTHENTICATOR_MAX_OPTIONS 256
struct DCB;
struct server;
struct SERVER;
struct MXS_SESSION;
/**

View File

@ -33,7 +33,7 @@
MXS_BEGIN_DECLS
struct server;
struct SERVER;
/**
* Buffer properties - used to store properties related to the buffer
@ -126,7 +126,7 @@ typedef struct gwbuf
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 */
struct SERVER* server; /*< The target server where the buffer is executed */
uint32_t gwbuf_type; /*< buffer's data type information */
#ifdef SS_DEBUG
int owner; /*< Owner of the thread, only for debugging */

View File

@ -422,7 +422,7 @@ SERVICE* config_get_service(const MXS_CONFIG_PARAMETER* params, const char* key)
*
* @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,
@ -435,7 +435,7 @@ struct server* config_get_server(const MXS_CONFIG_PARAMETER* params, const char*
*/
int config_get_server_list(const MXS_CONFIG_PARAMETER* params,
const char* key,
struct server*** output);
struct SERVER*** output);
/**
* Get a compiled regular expression and the ovector size of the pattern. The

View File

@ -35,7 +35,7 @@ MXS_BEGIN_DECLS
#define ERRHANDLE
struct MXS_SESSION;
struct server;
struct SERVER;
struct DCB;
@ -193,7 +193,7 @@ struct DCB : public MXB_POLL_DATA
void* authenticator_data = nullptr;/**< The authenticator data for this DCB */
DCB_CALLBACK* callbacks = nullptr; /**< The list of callbacks for the DCB */
int64_t last_read = 0; /**< Last time the DCB received data */
struct server* server = nullptr; /**< The associated backend server */
struct SERVER* server = nullptr; /**< The associated backend server */
SSL* ssl = nullptr; /**< SSL struct for connection */
bool ssl_read_want_read = false;
bool ssl_read_want_write = false;
@ -241,7 +241,7 @@ void dcb_global_init();
int dcb_write(DCB*, GWBUF*);
DCB* dcb_alloc(DCB::Role, MXS_SESSION*);
DCB* dcb_connect(struct server*, MXS_SESSION*, const char*);
DCB* dcb_connect(struct SERVER*, MXS_SESSION*, const char*);
int dcb_read(DCB*, GWBUF**, int);
int dcb_drain_writeq(DCB*);
void dcb_close(DCB*);
@ -275,7 +275,7 @@ int dcb_add_callback(DCB*, DCB_REASON, int (*)(DCB*, DCB_REASON, void*), void*);
int dcb_remove_callback(DCB*, DCB_REASON, int (*)(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 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);

View File

@ -26,7 +26,7 @@
MXS_BEGIN_DECLS
struct DCB;
struct server;
struct SERVER;
struct MXS_SESSION;
/**
@ -106,7 +106,7 @@ typedef struct mxs_protocol
*
* @return The opened file descriptor or DCBFD_CLOSED on error
*/
int32_t (* connect)(DCB* dcb, struct server* server, MXS_SESSION* session);
int32_t (* connect)(DCB* dcb, struct SERVER* server, MXS_SESSION* session);
/**
* Free protocol data allocated in the connect handler
@ -131,7 +131,7 @@ typedef struct mxs_protocol
*
* @note Currently the return value is ignored
*/
int32_t (* auth)(DCB* dcb, struct server* server, MXS_SESSION* session, GWBUF* buffer);
int32_t (* auth)(DCB* dcb, struct SERVER* server, MXS_SESSION* session, GWBUF* buffer);
/**
* Returns the name of the default authenticator module for this protocol

View File

@ -23,7 +23,7 @@
#define MAX_SERVER_MONUSER_LEN 1024
#define MAX_SERVER_MONPW_LEN 1024
#define MAX_SERVER_VERSION_LEN 256
#define MAX_NUM_SLAVES 128 /**< Maximum number of slaves under a single server*/
#define MAX_NUM_SLAVES 128 /**< Maximum number of slaves under a single server*/
/**
* Server configuration parameters names
@ -46,21 +46,17 @@ const int MAINTENANCE_FLAG_CHECK = -1;
// Default replication lag value
const int MXS_RLAG_UNDEFINED = -1;
/**
* The server parameters used for weighting routing decisions
*/
typedef struct server_params
/* Custom server parameters. These can be used by modules for e.g. weighting routing decisions. */
struct SERVER_PARAM
{
char* name; /**< Parameter name */
char* value; /**< Parameter value */
bool active; /**< Whether the parameter is valid */
struct server_params* next; /**< Next Paramter in the linked list */
} SERVER_PARAM;
char* name; /**< Parameter name */
char* value; /**< Parameter value */
bool active; /**< Whether the parameter is valid */
struct SERVER_PARAM* next; /**< Next Paramter in the linked list */
};
/**
* The server statistics structure
*/
typedef struct
/* Server connection and usage statistics */
struct SERVER_STATS
{
int n_connections; /**< Number of connections */
int n_current; /**< Current connections */
@ -69,23 +65,21 @@ typedef struct
uint64_t n_new_conn; /**< Times the current pool was empty */
uint64_t n_from_pool; /**< Times when a connection was available from the pool */
uint64_t packets; /**< Number of packets routed to this server */
} SERVER_STATS;
};
/**
* The server version.
*/
typedef struct server_version
/* Server version */
struct SERVER_VERSION
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} SERVER_VERSION;
};
typedef enum
enum server_type_t
{
SERVER_TYPE_MARIADB,
SERVER_TYPE_MYSQL
} server_type_t;
};
static inline void server_decode_version(uint64_t version, SERVER_VERSION* server_version)
{
@ -109,7 +103,7 @@ static uint64_t server_encode_version(const SERVER_VERSION* server_version)
* the name of a protocol module that is loaded to implement the protocol
* between the gateway and the server.
*/
typedef struct server
struct SERVER
{
// Base settings
char* name; /**< Server config name */
@ -126,7 +120,7 @@ typedef struct server
bool proxy_protocol; /**< Send proxy-protocol header to backends when connecting
* routing sessions. */
SERVER_PARAM* parameters; /**< Additional custom parameters which may affect routing
* decisions. */
* decisions. */
// Base variables
bool is_active; /**< Server is active and has not been "destroyed" */
void* auth_instance; /**< Authenticator instance data */
@ -158,7 +152,7 @@ typedef struct server
* by rwsplit. TODO: Move to rwsplit */
bool warn_ssl_not_enabled;/**< SSL not used for an SSL enabled server */
MxsDiskSpaceThreshold* disk_space_threshold;/**< Disk space thresholds */
} SERVER;
};
/**
* Status bits in the SERVER->status member, which describes the general state of a server. Although the

View File

@ -29,7 +29,7 @@
#include <maxscale/filter.hh>
#include <maxscale/server.hh>
struct server;
struct SERVER;
struct mxs_router;
struct mxs_router_object;
struct users;

View File

@ -29,7 +29,7 @@ struct mxs_filter_def;
struct mxs_filter;
struct mxs_filter_session;
struct mxs_router_session;
struct server;
struct SERVER;
class Listener;
using SListener = std::shared_ptr<Listener>;
@ -610,7 +610,7 @@ void session_retain_statement(MXS_SESSION* session, GWBUF* buffer);
* @param final_response True if this was the final server to respond,
* false otherwise.
*/
void session_book_server_response(MXS_SESSION* session, struct server* server, bool final_response);
void session_book_server_response(MXS_SESSION* session, struct SERVER* server, bool final_response);
/**
* @brief Reset the server bookkeeping for the current statement.

View File

@ -1920,7 +1920,7 @@ static void dcb_call_callback(DCB* dcb, DCB_REASON reason)
}
}
static void dcb_hangup_foreach_worker(MXB_WORKER* worker, struct server* server)
static void dcb_hangup_foreach_worker(MXB_WORKER* worker, struct SERVER* server)
{
RoutingWorker* rworker = static_cast<RoutingWorker*>(worker);
int id = rworker->id();
@ -1940,7 +1940,7 @@ static void dcb_hangup_foreach_worker(MXB_WORKER* worker, struct server* server)
*
* @param reason The DCB_REASON that triggers the callback
*/
void dcb_hangup_foreach(struct server* server)
void dcb_hangup_foreach(struct SERVER* server)
{
intptr_t arg1 = (intptr_t)dcb_hangup_foreach_worker;
intptr_t arg2 = (intptr_t)server;

View File

@ -36,7 +36,7 @@ public:
return *this;
}
struct server* server() const
struct SERVER* server() const
{
return (this->m_sInner.get()) ? m_sInner.get()->server : NULL;
}