Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
db48aac6
Commit
db48aac6
authored
Aug 23, 2010
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Plain Diff
Merge fix for BUG#54989 to mysql-5.5-bugfixing.
parents
0c2b883d
b8aceb70
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
15 deletions
+74
-15
sql/sql_audit.cc
sql/sql_audit.cc
+30
-14
sql/sql_audit.h
sql/sql_audit.h
+1
-0
sql/sql_plugin.cc
sql/sql_plugin.cc
+43
-1
No files found.
sql/sql_audit.cc
View file @
db48aac6
...
...
@@ -137,6 +137,30 @@ static my_bool acquire_plugins(THD *thd, plugin_ref plugin, void *arg)
}
/**
@brief Acquire audit plugins
@param[in] thd MySQL thread handle
@param[in] event_class Audit event class
@details Ensure that audit plugins interested in given event
class are locked by current thread.
*/
void
mysql_audit_acquire_plugins
(
THD
*
thd
,
uint
event_class
)
{
unsigned
long
event_class_mask
[
MYSQL_AUDIT_CLASS_MASK_SIZE
];
DBUG_ENTER
(
"mysql_audit_acquire_plugins"
);
set_audit_mask
(
event_class_mask
,
event_class
);
if
(
thd
&&
!
check_audit_mask
(
mysql_global_audit_mask
,
event_class_mask
)
&&
check_audit_mask
(
thd
->
audit_class_mask
,
event_class_mask
))
{
plugin_foreach
(
thd
,
acquire_plugins
,
MYSQL_AUDIT_PLUGIN
,
&
event_class
);
add_audit_mask
(
thd
->
audit_class_mask
,
event_class_mask
);
}
DBUG_VOID_RETURN
;
}
/**
Notify the audit system of an event
...
...
@@ -151,21 +175,8 @@ void mysql_audit_notify(THD *thd, uint event_class, uint event_subtype, ...)
{
va_list
ap
;
audit_handler_t
*
handlers
=
audit_handlers
+
event_class
;
unsigned
long
event_class_mask
[
MYSQL_AUDIT_CLASS_MASK_SIZE
];
DBUG_ASSERT
(
event_class
<
audit_handlers_count
);
set_audit_mask
(
event_class_mask
,
event_class
);
/*
Check to see if we have acquired the audit plugins for the
required audit event classes.
*/
if
(
thd
&&
check_audit_mask
(
thd
->
audit_class_mask
,
event_class_mask
))
{
plugin_foreach
(
thd
,
acquire_plugins
,
MYSQL_AUDIT_PLUGIN
,
&
event_class
);
add_audit_mask
(
thd
->
audit_class_mask
,
event_class_mask
);
}
mysql_audit_acquire_plugins
(
thd
,
event_class
);
va_start
(
ap
,
event_subtype
);
(
*
handlers
)(
thd
,
event_subtype
,
ap
);
va_end
(
ap
);
...
...
@@ -448,6 +459,11 @@ static void event_class_dispatch(THD *thd, const struct mysql_event *event)
#else
/* EMBEDDED_LIBRARY */
void
mysql_audit_acquire_plugins
(
THD
*
thd
,
uint
event_class
)
{
}
void
mysql_audit_initialize
()
{
}
...
...
sql/sql_audit.h
View file @
db48aac6
...
...
@@ -29,6 +29,7 @@ extern void mysql_audit_finalize();
extern
void
mysql_audit_init_thd
(
THD
*
thd
);
extern
void
mysql_audit_free_thd
(
THD
*
thd
);
extern
void
mysql_audit_acquire_plugins
(
THD
*
thd
,
uint
event_class
);
extern
void
mysql_audit_notify
(
THD
*
thd
,
uint
event_class
,
...
...
sql/sql_plugin.cc
View file @
db48aac6
...
...
@@ -29,7 +29,7 @@
#include "records.h" // init_read_record, end_read_record
#include <my_pthread.h>
#include <my_getopt.h>
#include
<mysql/plugin_audit.h>
#include
"sql_audit.h"
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
#define REPORT_TO_LOG 1
#define REPORT_TO_USER 2
...
...
@@ -1709,6 +1709,27 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
MYSQL_LOCK_IGNORE_TIMEOUT
)))
DBUG_RETURN
(
TRUE
);
/*
Pre-acquire audit plugins for events that may potentially occur
during [UN]INSTALL PLUGIN.
When audit event is triggered, audit subsystem acquires interested
plugins by walking through plugin list. Evidently plugin list
iterator protects plugin list by acquiring LOCK_plugin, see
plugin_foreach_with_mask().
On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin
rather for a long time.
When audit event is triggered during [UN]INSTALL PLUGIN, plugin
list iterator acquires the same lock (within the same thread)
second time.
This hack should be removed when LOCK_plugin is fixed so it
protects only what it supposed to protect.
*/
mysql_audit_acquire_plugins
(
thd
,
MYSQL_AUDIT_GENERAL_CLASS
);
mysql_mutex_lock
(
&
LOCK_plugin
);
mysql_rwlock_wrlock
(
&
LOCK_system_variables_hash
);
...
...
@@ -1789,6 +1810,27 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
if
(
!
(
table
=
open_ltable
(
thd
,
&
tables
,
TL_WRITE
,
MYSQL_LOCK_IGNORE_TIMEOUT
)))
DBUG_RETURN
(
TRUE
);
/*
Pre-acquire audit plugins for events that may potentially occur
during [UN]INSTALL PLUGIN.
When audit event is triggered, audit subsystem acquires interested
plugins by walking through plugin list. Evidently plugin list
iterator protects plugin list by acquiring LOCK_plugin, see
plugin_foreach_with_mask().
On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin
rather for a long time.
When audit event is triggered during [UN]INSTALL PLUGIN, plugin
list iterator acquires the same lock (within the same thread)
second time.
This hack should be removed when LOCK_plugin is fixed so it
protects only what it supposed to protect.
*/
mysql_audit_acquire_plugins
(
thd
,
MYSQL_AUDIT_GENERAL_CLASS
);
mysql_mutex_lock
(
&
LOCK_plugin
);
if
(
!
(
plugin
=
plugin_find_internal
(
name
,
MYSQL_ANY_PLUGIN
)))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment