mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-27 00:32:07 +01:00
Syncronization issues
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3409 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
9d2eafdc49
commit
55d921645d
1 changed files with 19 additions and 9 deletions
|
@ -79,8 +79,15 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
private List proxies;
|
||||
|
||||
private List streamHosts;
|
||||
|
||||
// locks the proxies during their initialization process
|
||||
private final Object proxyLock = new Object();
|
||||
|
||||
private ProxyProcess proxyProcess;
|
||||
|
||||
// locks on the proxy process during its initiatilization process
|
||||
private final Object processLock = new Object();
|
||||
|
||||
public Socks5TransferNegotiator(final XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
@ -101,7 +108,6 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
|
||||
Bytestream streamHostsInfo = (Bytestream) streamInitiation;
|
||||
|
||||
|
||||
if (streamHostsInfo.getType().equals(IQ.Type.ERROR)) {
|
||||
throw new XMPPException(streamHostsInfo.getError());
|
||||
}
|
||||
|
@ -345,10 +351,12 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
}
|
||||
|
||||
private ProxyProcess establishListeningSocket() throws IOException {
|
||||
synchronized (processLock) {
|
||||
if (proxyProcess == null) {
|
||||
proxyProcess = new ProxyProcess(new ServerSocket(7777));
|
||||
proxyProcess.start();
|
||||
}
|
||||
}
|
||||
proxyProcess.addTransfer();
|
||||
return proxyProcess;
|
||||
}
|
||||
|
@ -396,7 +404,6 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
*/
|
||||
private Bytestream createByteStreamInit(final String from, final String to,
|
||||
final String sid, final String localIP, final int port) {
|
||||
|
||||
Bytestream bs = new Bytestream();
|
||||
bs.setTo(to);
|
||||
bs.setFrom(from);
|
||||
|
@ -406,9 +413,12 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
if (localIP != null && port > 0) {
|
||||
bs.addStreamHost(from, localIP, port);
|
||||
}
|
||||
// make sure the proxies have been initialized completely
|
||||
synchronized (proxyLock) {
|
||||
if (proxies == null) {
|
||||
initProxies();
|
||||
}
|
||||
}
|
||||
if (streamHosts != null) {
|
||||
Iterator it = streamHosts.iterator();
|
||||
while (it.hasNext()) {
|
||||
|
@ -728,7 +738,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
synchronized (this) {
|
||||
if (transfers == -1) {
|
||||
transfers = 1;
|
||||
thread.notify();
|
||||
this.notify();
|
||||
}
|
||||
else {
|
||||
transfers++;
|
||||
|
|
Loading…
Reference in a new issue