summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Voormann2014-01-28 10:01:44 (EST)
committerPaul Webster2014-01-28 19:39:47 (EST)
commit30ba8ea359acc60d26bbbc47684874777aefaff0 (patch)
tree61cad973ccd5495ace5a87ddc43ee7849cf3da92
parent7af2f53a15d3ac22f9f26232073e89d9c2b3e00d (diff)
downloadeclipse.platform.ua-30ba8ea359acc60d26bbbc47684874777aefaff0.zip
eclipse.platform.ua-30ba8ea359acc60d26bbbc47684874777aefaff0.tar.gz
eclipse.platform.ua-30ba8ea359acc60d26bbbc47684874777aefaff0.tar.bz2
Bug 426785 - [Help][Search] Querying help content while exiting Eclipse mayrefs/changes/24/21224/2
cause a deadlock preventing a proper shutdown In org.eclipse.help.internal.search.SearchIndex deadlock removed: The method "close()" waits for all searches to finish. But the code to wait was enclosed by the same "synchronized (searches) {...}" as in "unregisterSearch(Thread t)", which must be called to finish a search. To avoid the deadlock the code to wait has been moved outside the "synchronized" block. Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=426785 Signed-off-by: Holger Voormann <eclipse@voormann.de> Change-Id: Ib3ffbe4e7c75ad7b6bcb359cb8788650f2eabbf7
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java30
1 files changed, 17 insertions, 13 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
index e860c8d..3302840 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Holger Voormann - fix for bug 426785 (http://eclip.se/426785)
*******************************************************************************/
package org.eclipse.help.internal.search;
@@ -121,7 +122,7 @@ public class SearchIndex implements IHelpSearchIndex {
private HelpProperties dependencies;
- private boolean closed = false;
+ private volatile boolean closed = false;
// Collection of searches occuring now
private Collection<Thread> searches = new ArrayList<Thread>();
@@ -803,20 +804,23 @@ public class SearchIndex implements IHelpSearchIndex {
*/
public void close() {
closed = true;
- // wait for all sarches to finish
- synchronized (searches) {
- while (searches.size() > 0) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException ie) {
+
+ // wait for all searches to finish
+ while (true) {
+ synchronized (searches) {
+ if (searches.isEmpty()) {
+ if (searcher != null) {
+ try {
+ searcher.close();
+ } catch (IOException ioe) {
+ }
+ }
+ break;
}
}
- //
- if (searcher != null) {
- try {
- searcher.close();
- } catch (IOException ioe) {
- }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException ie) {
}
}
}