Date: Mon, 6 May 2002 14:56:21 -0700 (PDT) From: "Andrew R. Reiter" <arr@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 10905 for review Message-ID: <200205062156.g46LuLU28049@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205062156.g46LuLU28049>