Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
xmpp socket fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kryukov committed Nov 27, 2013
1 parent ec07b47 commit 1f1185c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions networking/src/protocol/xmpp/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
final class Socket implements Runnable {
private TcpSocket socket = new TcpSocket();
private boolean connected;
private volatile boolean connected;
private byte[] inputBuffer = new byte[1024];
private int inputBufferLength = 0;
public int inputBufferIndex = 0;
Expand All @@ -33,7 +33,8 @@ final class Socket implements Runnable {
private boolean secured;
// #sijapp cond.end #
private final Vector<Object> read = new Vector<Object>();

private final Object readLock = new Object();

/**
* Creates a new instance of Socket
*/
Expand Down Expand Up @@ -175,6 +176,12 @@ boolean isSecured() {
@Override
public void run() {
while (connected) {
synchronized (readLock) {
try {
readLock.wait();
} catch (InterruptedException ignored) {
}
}
Object readObject;
try {
readObject = XmlNode.parse(this);
Expand All @@ -184,7 +191,7 @@ public void run() {
}
synchronized (read) {
read.addElement(readObject);
read.notify();
read.notifyAll();
}
}
synchronized (read) {
Expand All @@ -193,6 +200,9 @@ public void run() {
}
public XmlNode readNode(boolean wait) throws JimmException {
Object readObject = null;
synchronized (readLock) {
readLock.notify();
}
synchronized (read) {
do {
if (0 < read.size()) {
Expand Down

0 comments on commit 1f1185c

Please sign in to comment.