mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Added per thread status variables, after review, patch v1.1.
This commit is contained in:
@ -297,6 +297,7 @@ void THD::init(void)
|
||||
bzero((char*) warn_count, sizeof(warn_count));
|
||||
total_warn_count= 0;
|
||||
update_charset();
|
||||
bzero((char *) &status_var, sizeof(status_var));
|
||||
}
|
||||
|
||||
|
||||
@ -387,6 +388,7 @@ THD::~THD()
|
||||
/* Ensure that no one is using THD */
|
||||
pthread_mutex_lock(&LOCK_delete);
|
||||
pthread_mutex_unlock(&LOCK_delete);
|
||||
add_to_status(&global_status_var, &status_var);
|
||||
|
||||
/* Close connection */
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
@ -429,6 +431,27 @@ THD::~THD()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Add to one status variable another status variable
|
||||
|
||||
NOTES
|
||||
This function assumes that all variables are long/ulong.
|
||||
If this assumption will change, then we have to explictely add
|
||||
the other variables after the while loop
|
||||
*/
|
||||
|
||||
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
|
||||
{
|
||||
ulong *end= (ulong*) ((byte*) to_var + offsetof(STATUS_VAR,
|
||||
last_system_status_var) +
|
||||
sizeof(ulong));
|
||||
ulong *to= (ulong*) to_var, *from= (ulong*) from_var;
|
||||
|
||||
while (to != end)
|
||||
*(to++)+= *(from++);
|
||||
}
|
||||
|
||||
|
||||
void THD::awake(THD::killed_state state_to_set)
|
||||
{
|
||||
THD_CHECK_SENTRY(this);
|
||||
@ -1553,3 +1576,27 @@ void TMP_TABLE_PARAM::init()
|
||||
group_parts= group_length= group_null_parts= 0;
|
||||
quick_group= 1;
|
||||
}
|
||||
|
||||
|
||||
void thd_increment_bytes_sent(ulong length)
|
||||
{
|
||||
current_thd->status_var.bytes_sent+= length;
|
||||
}
|
||||
|
||||
|
||||
void thd_increment_bytes_received(ulong length)
|
||||
{
|
||||
current_thd->status_var.bytes_received+= length;
|
||||
}
|
||||
|
||||
|
||||
void thd_increment_net_big_packet_count(ulong length)
|
||||
{
|
||||
current_thd->status_var.net_big_packet_count+= length;
|
||||
}
|
||||
|
||||
|
||||
void THD::set_status_var_init()
|
||||
{
|
||||
bzero((char*) &status_var, sizeof(status_var));
|
||||
}
|
||||
|
Reference in New Issue
Block a user