diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-10-28 08:28:39 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-10-28 08:28:39 +0300 |
commit | 3a79e5fd317316c293baa459e8296fdb0744c280 (patch) | |
tree | 9ff2059bbd651715daa6a1d7241c0ddd303c0071 /plugin | |
parent | 7948a1dc53eccc23095a83daa5fd6b3bfaedf7f2 (diff) | |
parent | 657bcf928eb1c6a80ee2c82f0dcdd59ab02927e4 (diff) | |
download | mariadb-git-3a79e5fd317316c293baa459e8296fdb0744c280.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/server_audit/server_audit.c | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 228f261b333..7a170b13b27 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -301,8 +301,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[256]; @@ -561,18 +559,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. */ @@ -1727,7 +1717,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; @@ -1736,6 +1726,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; @@ -1818,17 +1809,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; @@ -1874,8 +1857,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; } @@ -2524,7 +2507,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); @@ -2609,10 +2591,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"); |