diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-01-06 14:15:38 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-01-06 14:15:38 +0000 |
commit | 5d645da259a65e375831e3be6d10227e360339ed (patch) | |
tree | 07fa1fc23dc1fa7720b85e2f8f098307fa6f4acb /sys/security | |
parent | d71ad1411f46ae63fbed91fcf86278f6f0d4aa73 (diff) | |
download | FreeBSD-src-5d645da259a65e375831e3be6d10227e360339ed.zip FreeBSD-src-5d645da259a65e375831e3be6d10227e360339ed.tar.gz |
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.
Diffstat (limited to 'sys/security')
-rw-r--r-- | sys/security/audit/audit_pipe.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/security/audit/audit_pipe.c b/sys/security/audit/audit_pipe.c index ef4fc83..afc7d54 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); |