From owner-p4-projects Mon May 6 14:57:38 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AE51A37B403; Mon, 6 May 2002 14:56:25 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id CA1C237B404 for ; Mon, 6 May 2002 14:56:21 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g46LuLU28049 for perforce@freebsd.org; Mon, 6 May 2002 14:56:21 -0700 (PDT) (envelope-from arr@freebsd.org) Date: Mon, 6 May 2002 14:56:21 -0700 (PDT) Message-Id: <200205062156.g46LuLU28049@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to arr@freebsd.org using -f From: "Andrew R. Reiter" Subject: PERFORCE change 10905 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=10905 Change 10905 by arr@arr_shibby on 2002/05/06 14:55:44 - Move kthread_create out of the audit_init routine and make it its own SYSINIT. Rather than starting up the writer thread via kthread_create, we use kproc_start in a similar fashion to the bufdaemon startup code. - Make audit_write_thread have a void argument. - Change the locking with audit_write_thread to use msleep. - Change SYSINITs to have the system init value followed by the order within that system for the routine to be called. This unbreaks initializing the audit system. - Other various changes related to making things work. Affected files ... ... //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#32 edit Differences ... ==== //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#32 (text+ko) ==== @@ -54,6 +54,7 @@ */ struct mtx audit_q_mtx; struct mtx audit_z_mtx; + struct audit_record_list record_queue; static uma_zone_t record_zone; static int audit_shutdown_flag = 0; @@ -66,7 +67,6 @@ * static size_t pool_size = 32; */ - audit_record_t * audit_record_init(int type, size_t evsz) { @@ -108,10 +108,17 @@ panic("audit_init: unable to init audit record zone"); TAILQ_INIT(&record_queue); audit_shutdown_flag = 0; - (void)kthread_create(&audit_write_thread, NULL, NULL, RFNOWAIT, - "TrustedBSD audit write thread"); } -SYSINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_init, NULL); +SYSINIT(tbsd_audit, SI_SUB_MAC, SI_ORDER_ANY, &audit_init, NULL); + +static struct proc *auditproc; +static struct kproc_desc auditdesc = { + "audit", + audit_write_thread, + &auditproc +}; +SYSINIT(audit_thread, SI_SUB_KTHREAD_UPDATE, SI_ORDER_ANY, kproc_start, + &auditdesc); void audit_shutdown(void) @@ -121,32 +128,25 @@ uma_zdestroy(record_zone); mtx_destroy(&audit_q_mtx); mtx_destroy(&audit_z_mtx); -} -SYSUNINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_shutdown, NULL); +}; +SYSUNINIT(tbsd_audit, SI_SUB_MAC, SI_ORDER_ANY, &audit_shutdown, NULL); void -audit_write_thread(void *arg) +audit_write_thread(void) { audit_record_t *ar; mtx_lock(&audit_q_mtx); for (;;) { ar = NULL; - TAILQ_REMOVE(&record_queue, ar, ar_next); - - /* - * If we don't exit, we might try to zfree - * an object that no longer has a zone.. Oof. - */ - if (audit_shutdown_flag) { - mtx_unlock(&audit_q_mtx); + if (audit_shutdown_flag) kthread_exit(0); + if (!TAILQ_EMPTY(&record_queue)) { + ar = TAILQ_FIRST(&record_queue); + TAILQ_REMOVE(&record_queue, ar, ar_next); } - if (ar != NULL) uma_zfree(record_zone, ar); - else - msleep(&record_queue, &audit_q_mtx, PWAIT, - "record queue", 0); + msleep(&record_queue, &audit_q_mtx, PWAIT, "record queue", 0); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message