Date: Wed, 4 Jul 2007 11:10:37 GMT From: Zhouyi ZHOU <zhouzhouyi@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122849 for review Message-ID: <200707041110.l64BAbsK049148@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122849 Change 122849 by zhouzhouyi@zhouzhouyi_mactest on 2007/07/04 11:10:10 Wait until all the record is stored to the disk Affected files ... .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test_log.c#3 edit Differences ... ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test_log.c#3 (text+ko) ==== @@ -71,7 +71,9 @@ static int mac_test_can_log = 0; static struct mtx mac_test_log_mtx; static struct mtx mac_test_submit_mtx; +static struct mtx mac_test_wait_close; struct cv mac_test_worker_cv; +struct cv mac_test_wait_for_empty; struct mac_test_log_entry { void *mte_record; @@ -140,6 +142,12 @@ mac_test_log_isopen = 0; mac_test_can_log = 0; mtx_unlock(&mac_test_log_mtx); + mtx_lock(&mac_test_wait_close); + while(!TAILQ_EMPTY(&mac_test_log_list)){ + cv_wait(&mac_test_wait_for_empty, &mac_test_wait_close); + continue; + } + mtx_unlock(&mac_test_wait_close); vn_close(logvnode, O_CREAT|O_TRUNC|FWRITE, curthread->td_ucred, curthread); return (0); @@ -211,6 +219,8 @@ VFS_UNLOCK_GIANT(vfslocked); free(mte->mte_record, M_MAC_TEST_LOG); free(mte, M_MAC_TEST_LOG); + if (TAILQ_EMPTY(&mac_test_log_list)) + cv_signal(&mac_test_wait_for_empty); mtx_lock(&mac_test_submit_mtx); } } @@ -223,7 +233,9 @@ /* Create the special device file. */ mtx_init(&mac_test_log_mtx, "mac_test_log_mtx", NULL, MTX_DEF); mtx_init(&mac_test_submit_mtx, "mac_test_submit_mtx", NULL, MTX_DEF); + mtx_init(&mac_test_wait_close, "mac_test_wait_close", NULL, MTX_DEF); cv_init(&mac_test_worker_cv, "mac_test_worker_cv"); + cv_init(&mac_test_wait_for_empty, "mac_test_wait_for_empty"); TAILQ_INIT(&mac_test_log_list); mac_test_log_dev = make_dev(&mac_test_cdevsw, 0, UID_ROOT, GID_KMEM, 0600, MAC_TEST_LOG_FILENAME);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707041110.l64BAbsK049148>