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.
This commit is contained in:
Robert Watson 2009-01-06 14:15:38 +00:00
parent 16c6e0979c
commit d423f266c4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186825

View File

@ -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);