From 5d645da259a65e375831e3be6d10227e360339ed Mon Sep 17 00:00:00 2001 From: rwatson Date: Tue, 6 Jan 2009 14:15:38 +0000 Subject: 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. --- sys/security/audit/audit_pipe.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sys/security') 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); -- cgit v1.1