diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/xml/TagWriter.java | 15 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/XmppConnection.java | 5 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/xml/TagWriter.java b/src/main/java/de/pixart/messenger/xml/TagWriter.java index 7c25fdf4a..3f4d011a2 100644 --- a/src/main/java/de/pixart/messenger/xml/TagWriter.java +++ b/src/main/java/de/pixart/messenger/xml/TagWriter.java @@ -13,15 +13,14 @@ import de.pixart.messenger.xmpp.stanzas.AbstractStanza; public class TagWriter { private OutputStreamWriter outputStream; - private boolean finshed = false; + private boolean finished = false; private LinkedBlockingQueue<AbstractStanza> writeQueue = new LinkedBlockingQueue<AbstractStanza>(); private Thread asyncStanzaWriter = new Thread() { - private boolean shouldStop = false; @Override public void run() { - while (!shouldStop) { - if ((finshed) && (writeQueue.size() == 0)) { + while (!isInterrupted()) { + if (finished && writeQueue.size() == 0) { return; } try { @@ -29,7 +28,7 @@ public class TagWriter { outputStream.write(output.toString()); outputStream.flush(); } catch (Exception e) { - shouldStop = true; + return; } } } @@ -73,7 +72,7 @@ public class TagWriter { } public TagWriter writeStanzaAsync(AbstractStanza stanza) { - if (finshed) { + if (finished) { Log.d(Config.LOGTAG, "attempting to write stanza to finished TagWriter"); return this; } else { @@ -90,7 +89,7 @@ public class TagWriter { } public void finish() { - this.finshed = true; + this.finished = true; } public boolean finished() { @@ -102,7 +101,7 @@ public class TagWriter { } public synchronized void forceClose() { - finish(); + asyncStanzaWriter.interrupt(); if (outputStream != null) { try { outputStream.close(); diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index d3132961f..3d7961980 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -228,7 +228,8 @@ public class XmppConnection implements Runnable { protected synchronized void changeStatus(final Account.State nextStatus) { if (Thread.currentThread().isInterrupted()) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": not changing status to "+nextStatus+" because thread was interrupted"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": not changing status to " + nextStatus + " because thread was interrupted"); + return; } if (account.getStatus() != nextStatus) { if ((nextStatus == Account.State.OFFLINE) @@ -485,7 +486,7 @@ public class XmppConnection implements Runnable { * * @return true if server returns with valid xmpp, false otherwise */ - private boolean startXmpp(Socket socket) throws Exception { + private synchronized boolean startXmpp(Socket socket) throws Exception { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } |