reformating and upper bound for waiting on stanza writer

This commit is contained in:
Daniel Gultsch 2015-08-28 11:42:11 +02:00
parent 5298f4e2aa
commit 384c441990
1 changed files with 16 additions and 8 deletions

View File

@ -722,11 +722,11 @@ public class XmppConnection implements Runnable {
sendPostBindInitialization(); sendPostBindInitialization();
} }
} else { } else {
Log.d(Config.LOGTAG,account.getJid()+": disconnecting because of bind failure"); Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure");
disconnect(true); disconnect(true);
} }
} else { } else {
Log.d(Config.LOGTAG,account.getJid()+": disconnecting because of bind failure"); Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure");
disconnect(true); disconnect(true);
} }
} }
@ -751,7 +751,7 @@ public class XmppConnection implements Runnable {
for(OnIqPacketReceived callback : callbacks) { for(OnIqPacketReceived callback : callbacks) {
callback.onIqPacketReceived(account,failurePacket); callback.onIqPacketReceived(account,failurePacket);
} }
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done clearing iq callbacks. "+this.packetCallbacks.size()+" left"); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": done clearing iq callbacks. " + this.packetCallbacks.size() + " left");
} }
private void sendStartSession() { private void sendStartSession() {
@ -1036,15 +1036,23 @@ public class XmppConnection implements Runnable {
if (tagWriter.isActive()) { if (tagWriter.isActive()) {
tagWriter.finish(); tagWriter.finish();
try { try {
while (!tagWriter.finished() && socket.isConnected()) { int i = 0;
Log.d(Config.LOGTAG, "not yet finished"); boolean warned = false;
Thread.sleep(100); while (!tagWriter.finished() && socket.isConnected() && i <= 10) {
if (!warned) {
Log.d(Config.LOGTAG, account.getJid().toBareJid()+": waiting for tag writer to finish");
warned = true;
}
Thread.sleep(200);
i++;
}
if (warned) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": tag writer has finished");
} }
tagWriter.writeTag(Tag.end("stream:stream")); tagWriter.writeTag(Tag.end("stream:stream"));
socket.close(); socket.close();
} catch (final IOException e) { } catch (final IOException e) {
Log.d(Config.LOGTAG, Log.d(Config.LOGTAG,"io exception during disconnect");
"io exception during disconnect");
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
Log.d(Config.LOGTAG, "interrupted"); Log.d(Config.LOGTAG, "interrupted");
} }