51
52
static const uint32_t random_max= 0x3FFFFFFF;
52
53
static const double random_max_double= (double)0x3FFFFFFF;
55
static plugin::TableFunction* mysql_status_table_function_ptr= NULL;
54
57
ListenMySQLProtocol::~ListenMySQLProtocol()
56
59
/* This is strdup'd from the options */
77
80
return new (nothrow) ClientMySQLProtocol(new_fd, using_mysql41_protocol);
83
drizzled::atomic<uint64_t> ClientMySQLProtocol::connectionCount;
84
drizzled::atomic<uint64_t> ClientMySQLProtocol::failedConnections;
85
drizzled::atomic<uint64_t> ClientMySQLProtocol::connected;
80
87
ClientMySQLProtocol::ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg):
81
88
using_mysql41_protocol(using_mysql41_protocol_arg)
143
151
bool connection_is_valid;
153
connectionCount.increment();
154
connected.increment();
145
156
/* Use "connect_timeout" value during connection phase */
146
157
drizzleclient_net_set_read_timeout(&net, connect_timeout);
147
158
drizzleclient_net_set_write_timeout(&net, connect_timeout);
155
166
sendError(session->main_da.sql_errno(), session->main_da.message());
167
failedConnections.increment();
159
170
/* Connect completed, set read/write timeouts back to default */
160
171
drizzleclient_net_set_read_timeout(&net, read_timeout);
161
172
drizzleclient_net_set_write_timeout(&net, write_timeout);
887
898
static int init(drizzled::module::Context &context)
900
mysql_status_table_function_ptr= new MysqlProtocolStatus;
902
context.add(mysql_status_table_function_ptr);
890
903
/* Initialize random seeds for the MySQL algorithm with minimal changes. */
891
904
time_t seed_time= time(NULL);
892
905
random_seed1= seed_time % random_max;
1038
static int mysql_protocol_connection_count_func(drizzle_show_var *var, char *buff)
1040
var->type= SHOW_LONGLONG;
1042
*((uint64_t *)buff)= ClientMySQLProtocol::connectionCount;
1046
static int mysql_protocol_connected_count_func(drizzle_show_var *var, char *buff)
1048
var->type= SHOW_LONGLONG;
1050
*((uint64_t *)buff)= ClientMySQLProtocol::connected;
1054
static int mysql_protocol_failed_count_func(drizzle_show_var *var, char *buff)
1056
var->type= SHOW_LONGLONG;
1058
*((uint64_t *)buff)= ClientMySQLProtocol::failedConnections;
1062
static st_show_var_func_container mysql_protocol_connection_count=
1063
{ &mysql_protocol_connection_count_func };
1065
static st_show_var_func_container mysql_protocol_connected_count=
1066
{ &mysql_protocol_connected_count_func };
1068
static st_show_var_func_container mysql_protocol_failed_count=
1069
{ &mysql_protocol_failed_count_func };
1071
static drizzle_show_var mysql_protocol_status_variables[]= {
1073
(char*) &mysql_protocol_connection_count, SHOW_FUNC},
1075
(char*) &mysql_protocol_connected_count, SHOW_FUNC},
1076
{"Failed_connections",
1077
(char*) &mysql_protocol_failed_count, SHOW_FUNC},
1078
{NULL, NULL, SHOW_LONGLONG}
1081
MysqlProtocolStatus::Generator::Generator(drizzled::Field **fields) :
1082
plugin::TableFunction::Generator(fields)
1084
status_var_ptr= mysql_protocol_status_variables;
1087
bool MysqlProtocolStatus::Generator::populate()
1089
MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
1090
char * const buff= (char *) &buff_data;
1091
drizzle_show_var tmp;
1093
if (status_var_ptr->name)
1095
std::ostringstream oss;
1096
string return_value;
1100
push(status_var_ptr->name);
1102
if (status_var_ptr->type == SHOW_FUNC)
1104
((mysql_show_var_func)((st_show_var_func_container *)status_var_ptr->value)->func)(&tmp, buff);
1110
value= status_var_ptr->value;
1111
type= status_var_ptr->type;
1117
oss << *(uint64_t*) value;
1118
return_value= oss.str();
1123
if (return_value.length())
1025
1135
DRIZZLE_DECLARE_PLUGIN
1027
1137
DRIZZLE_VERSION_ID,