summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 09:08:58 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 09:08:58 +0300
commitd8c6c53a0658ea8315252997f65d796b13182387 (patch)
tree26cb3a48c75fb94307ee564185b45fd7d94f80f7 /plugin
parent1ad1d789815ddada89d8fb557a47a437d1ea21c2 (diff)
parenta8ded395578ccab9c256b9beee7e62d4ada08522 (diff)
downloadmariadb-git-d8c6c53a0658ea8315252997f65d796b13182387.tar.gz
Merge 10.5 into 10.6
Diffstat (limited to 'plugin')
-rw-r--r--plugin/server_audit/server_audit.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index 49d41627275..d38d8ecc114 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -309,8 +309,6 @@ static char logging;
static volatile int internal_stop_logging= 0;
static char incl_user_buffer[1024];
static char excl_user_buffer[1024];
-static char *big_buffer= NULL;
-static size_t big_buffer_alloced= 0;
static unsigned int query_log_limit= 0;
static char servhost[HOSTNAME_LENGTH+1];
@@ -569,18 +567,10 @@ static PSI_mutex_info mutex_key_list[]=
{
{ &key_LOCK_operations, "SERVER_AUDIT_plugin::lock_operations",
PSI_FLAG_GLOBAL}
-#ifndef FLOGGER_NO_PSI
- ,
- { &key_LOCK_atomic, "SERVER_AUDIT_plugin::lock_atomic",
- PSI_FLAG_GLOBAL},
- { &key_LOCK_bigbuffer, "SERVER_AUDIT_plugin::lock_bigbuffer",
- PSI_FLAG_GLOBAL}
-#endif /*FLOGGER_NO_PSI*/
};
#endif /*HAVE_PSI_INTERFACE*/
static mysql_prlock_t lock_operations;
static mysql_mutex_t lock_atomic;
-static mysql_mutex_t lock_bigbuffer;
/* The Percona server and partly MySQL don't support */
/* launching client errors in the 'update_variable' methods. */
@@ -1744,7 +1734,7 @@ static int log_statement_ex(const struct connection_info *cn,
int error_code, const char *type, int take_lock)
{
size_t csize;
- char message_loc[1024];
+ char message_loc[2048];
char *message= message_loc;
size_t message_size= sizeof(message_loc);
char *uh_buffer;
@@ -1753,6 +1743,7 @@ static int log_statement_ex(const struct connection_info *cn,
unsigned int db_length;
long long query_id;
int result;
+ char *big_buffer= NULL;
if ((db= cn->db))
db_length= cn->db_length;
@@ -1835,17 +1826,9 @@ do_log_query:
if (query_len > (message_size - csize)/2)
{
- flogger_mutex_lock(&lock_bigbuffer);
- if (big_buffer_alloced < (query_len * 2 + csize))
- {
- big_buffer_alloced= (query_len * 2 + csize + 4095) & ~4095L;
- big_buffer= realloc(big_buffer, big_buffer_alloced);
- if (big_buffer == NULL)
- {
- big_buffer_alloced= 0;
- return 0;
- }
- }
+ size_t big_buffer_alloced= (query_len * 2 + csize + 4095) & ~4095L;
+ if(!(big_buffer= malloc(big_buffer_alloced)))
+ return 0;
memcpy(big_buffer, message, csize);
message= big_buffer;
@@ -1891,8 +1874,8 @@ do_log_query:
"\',%d", error_code);
message[csize]= '\n';
result= write_log(message, csize + 1, take_lock);
- if (message == big_buffer)
- flogger_mutex_unlock(&lock_bigbuffer);
+ if (big_buffer)
+ free(big_buffer);
return result;
}
@@ -2548,7 +2531,6 @@ static int server_audit_init(void *p __attribute__((unused)))
#endif
mysql_prlock_init(key_LOCK_operations, &lock_operations);
flogger_mutex_init(key_LOCK_operations, &lock_atomic, MY_MUTEX_INIT_FAST);
- flogger_mutex_init(key_LOCK_operations, &lock_bigbuffer, MY_MUTEX_INIT_FAST);
coll_init(&incl_user_coll);
coll_init(&excl_user_coll);
@@ -2633,10 +2615,8 @@ static int server_audit_deinit(void *p __attribute__((unused)))
else if (output_type == OUTPUT_SYSLOG)
closelog();
- (void) free(big_buffer);
mysql_prlock_destroy(&lock_operations);
flogger_mutex_destroy(&lock_atomic);
- flogger_mutex_destroy(&lock_bigbuffer);
error_header();
fprintf(stderr, "STOPPED\n");