Applies first part of Carl Hasselskog patch: UPnP potential deadlock, Connector closing, CandidateHarvesterSet thread pool merged.

This commit is contained in:
chenzo 2012-09-12 10:03:22 +00:00
parent 0ee1c41582
commit 8f51251658
3 changed files with 9 additions and 6 deletions

View File

@ -36,6 +36,11 @@ public class CandidateHarvesterSet
private final Collection<CandidateHarvesterSetElement> elements private final Collection<CandidateHarvesterSetElement> elements
= new LinkedList<CandidateHarvesterSetElement>(); = new LinkedList<CandidateHarvesterSetElement>();
/**
* A pool of thread used for gathering process.
*/
private static ExecutorService threadPool = Executors.newCachedThreadPool();
/** /**
* Initializes a new <tt>CandidateHarvesterSet</tt> instance. * Initializes a new <tt>CandidateHarvesterSet</tt> instance.
*/ */
@ -82,10 +87,7 @@ public class CandidateHarvesterSet
{ {
synchronized (elements) synchronized (elements)
{ {
harvest( harvest(elements.iterator(), component, threadPool);
elements.iterator(),
component,
Executors.newCachedThreadPool());
} }
} }

View File

@ -96,9 +96,9 @@ public class UPNPHarvester
wanIPThread.start(); wanIPThread.start();
wanPPPThread.start(); wanPPPThread.start();
while(finishThreads != 2) synchronized(rootSync)
{ {
synchronized(rootSync) while(finishThreads != 2)
{ {
rootSync.wait(); rootSync.wait();
} }

View File

@ -246,6 +246,7 @@ class Connector
synchronized(sockLock) synchronized(sockLock)
{ {
this.running = false; this.running = false;
this.sock.close();
this.sock = null; this.sock = null;
} }
} }