代码拉取完成,页面将自动刷新
同步操作将从 OpenCloudOS Stream/clucene 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From bdc374bfbb0ca34ddb40713eb51d8535fdf11952 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Wed, 31 Jul 2019 16:27:33 +0200
Subject: [PATCH 2/2] Avoid deadlock in TestIndexSearcher
---
src/test/search/TestIndexSearcher.cpp | 51 +++++++++++++++++++++------
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/src/test/search/TestIndexSearcher.cpp b/src/test/search/TestIndexSearcher.cpp
index 02c21aaf..a6dde5ba 100644
--- a/src/test/search/TestIndexSearcher.cpp
+++ b/src/test/search/TestIndexSearcher.cpp
@@ -8,9 +8,11 @@
DEFINE_MUTEX(searchMutex);
DEFINE_CONDITION(searchCondition);
+bool searchReady;
DEFINE_MUTEX(deleteMutex);
DEFINE_CONDITION(deleteCondition);
+bool deleteReady;
_LUCENE_THREAD_FUNC(searchDocs, _searcher) {
@@ -19,15 +21,20 @@ _LUCENE_THREAD_FUNC(searchDocs, _searcher) {
Query * query = QueryParser::parse(_T("one"), _T("content"), &an);
Hits * hits = searcher->search(query);
-// _LUCENE_SLEEP(9999); //make sure that searchMutex is being waited on...
+ {
+ SCOPED_LOCK_MUTEX(searchMutex);
+ searchReady = true;
+ CONDITION_NOTIFYALL(searchCondition);
+ }
- CONDITION_NOTIFYALL(searchCondition);
SCOPED_LOCK_MUTEX(deleteMutex);
_CLLDELETE(hits);
_CLLDELETE(query);
- CONDITION_WAIT(deleteMutex, deleteCondition);
+ while (!deleteReady) {
+ CONDITION_WAIT(deleteMutex, deleteCondition);
+ }
_LUCENE_THREAD_FUNC_RETURN(0);
}
@@ -55,13 +62,24 @@ void testEndThreadException(CuTest *tc) {
// this sequence is OK: delete searcher after search thread finish
{
+ searchReady = false;
+ deleteReady = false;
+
IndexSearcher * searcher = _CLNEW IndexSearcher(&ram);
_LUCENE_THREADID_TYPE thread = _LUCENE_THREAD_CREATE(&searchDocs, searcher);
- SCOPED_LOCK_MUTEX(searchMutex);
- CONDITION_WAIT(searchMutex, searchCondition);
-// _LUCENE_SLEEP(9999); //make sure that deleteMutex is being waited on...
- CONDITION_NOTIFYALL(deleteCondition);
+ {
+ SCOPED_LOCK_MUTEX(searchMutex);
+ while (!searchReady) {
+ CONDITION_WAIT(searchMutex, searchCondition);
+ }
+ }
+
+ {
+ SCOPED_LOCK_MUTEX(deleteMutex);
+ deleteReady = true;
+ CONDITION_NOTIFYALL(deleteCondition);
+ }
_LUCENE_THREAD_JOIN(thread);
@@ -71,14 +89,27 @@ void testEndThreadException(CuTest *tc) {
// this produces memory exception: delete searcher after search finish but before thread finish
{
+ searchReady = false;
+ deleteReady = false;
+
IndexSearcher * searcher = _CLNEW IndexSearcher(&ram);
_LUCENE_THREADID_TYPE thread = _LUCENE_THREAD_CREATE(&searchDocs, searcher);
- SCOPED_LOCK_MUTEX(searchMutex);
- CONDITION_WAIT(searchMutex, searchCondition);
+ {
+ SCOPED_LOCK_MUTEX(searchMutex);
+ while (!searchReady) {
+ CONDITION_WAIT(searchMutex, searchCondition);
+ }
+ }
+
searcher->close();
_CLLDELETE(searcher);
- CONDITION_NOTIFYALL(deleteCondition);
+
+ {
+ SCOPED_LOCK_MUTEX(deleteMutex);
+ deleteReady = true;
+ CONDITION_NOTIFYALL(deleteCondition);
+ }
_LUCENE_THREAD_JOIN(thread);
}
--
2.21.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。