aboutsummaryrefslogtreecommitdiff
path: root/sys/security
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2009-01-06 14:15:38 +0000
committerRobert Watson <rwatson@FreeBSD.org>2009-01-06 14:15:38 +0000
commitd423f266c4fc1939678262d5024de087b1291625 (patch)
tree07fa1fc23dc1fa7720b85e2f8f098307fa6f4acb /sys/security
parent16c6e0979cb363d299edf52fde068dd7e287025c (diff)
downloadsrc-d423f266c4fc1939678262d5024de087b1291625.tar.gz
src-d423f266c4fc1939678262d5024de087b1291625.zip
Do a lockless read of the audit pipe list before grabbing the audit pipe
lock in order to avoid the lock acquire hit if the pipe list is very likely empty. Obtained from: TrustedBSD Project MFC after: 3 weeks Sponsored by: Apple, Inc.
Notes
Notes: svn path=/head/; revision=186825
Diffstat (limited to 'sys/security')
-rw-r--r--sys/security/audit/audit_pipe.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/security/audit/audit_pipe.c b/sys/security/audit/audit_pipe.c
index ef4fc83d9e07..afc7d5473196 100644
--- a/sys/security/audit/audit_pipe.c
+++ b/sys/security/audit/audit_pipe.c
@@ -436,6 +436,10 @@ audit_pipe_preselect(au_id_t auid, au_event_t event, au_class_t class,
{
struct audit_pipe *ap;
+ /* Lockless read to avoid acquiring the global lock if not needed. */
+ if (TAILQ_EMPTY(&audit_pipe_list))
+ return (0);
+
AUDIT_PIPE_LIST_RLOCK();
TAILQ_FOREACH(ap, &audit_pipe_list, ap_list) {
AUDIT_PIPE_LOCK(ap);