PERFORCE change 122849 for review

Zhouyi ZHOU zhouzhouyi at FreeBSD.org
Wed Jul 4 11:10:38 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=122849

Change 122849 by zhouzhouyi at 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);


More information about the p4-projects mailing list