mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Merge branch '4.3'
This commit is contained in:
commit
d10319f1a0
2 changed files with 42 additions and 11 deletions
|
@ -1516,7 +1516,29 @@ public final class Roster extends Manager {
|
||||||
final Presence presence = (Presence) packet;
|
final Presence presence = (Presence) packet;
|
||||||
final Jid from = presence.getFrom();
|
final Jid from = presence.getFrom();
|
||||||
|
|
||||||
final BareJid key = from != null ? from.asBareJid() : null;
|
final BareJid key;
|
||||||
|
if (from != null) {
|
||||||
|
key = from.asBareJid();
|
||||||
|
} else {
|
||||||
|
XMPPConnection connection = connection();
|
||||||
|
if (connection == null) {
|
||||||
|
LOGGER.finest("Connection was null while trying to handle exotic presence stanza: " + presence);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Assume the presence come "from the users account on the server" since no from was set (RFC 6120 §
|
||||||
|
// 8.1.2.1 4.). Note that getUser() may return null, but should never return null in this case as where
|
||||||
|
// connected.
|
||||||
|
EntityFullJid myJid = connection.getUser();
|
||||||
|
if (myJid == null) {
|
||||||
|
LOGGER.info(
|
||||||
|
"Connection had no local address in Roster's presence listener."
|
||||||
|
+ " Possibly we received a presence without from before being authenticated."
|
||||||
|
+ " Presence: " + presence);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGGER.info("Exotic presence stanza without from received: " + presence);
|
||||||
|
key = myJid.asBareJid();
|
||||||
|
}
|
||||||
|
|
||||||
asyncButOrdered.performAsyncButOrdered(key, new Runnable() {
|
asyncButOrdered.performAsyncButOrdered(key, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -482,10 +482,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shutdown(boolean instant) {
|
private void shutdown(boolean instant) {
|
||||||
if (disconnectedButResumeable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First shutdown the writer, this will result in a closing stream element getting send to
|
// First shutdown the writer, this will result in a closing stream element getting send to
|
||||||
// the server
|
// the server
|
||||||
LOGGER.finer("PacketWriter shutdown()");
|
LOGGER.finer("PacketWriter shutdown()");
|
||||||
|
@ -503,6 +499,15 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
CloseableUtil.maybeClose(socket, LOGGER);
|
CloseableUtil.maybeClose(socket, LOGGER);
|
||||||
|
|
||||||
setWasAuthenticated();
|
setWasAuthenticated();
|
||||||
|
|
||||||
|
// Wait for reader and writer threads to be terminated.
|
||||||
|
readerWriterSemaphore.acquireUninterruptibly(2);
|
||||||
|
readerWriterSemaphore.release(2);
|
||||||
|
|
||||||
|
if (disconnectedButResumeable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If we are able to resume the stream, then don't set
|
// If we are able to resume the stream, then don't set
|
||||||
// connected/authenticated/usingTLS to false since we like behave like we are still
|
// connected/authenticated/usingTLS to false since we like behave like we are still
|
||||||
// connected (e.g. sendStanza should not throw a NotConnectedException).
|
// connected (e.g. sendStanza should not throw a NotConnectedException).
|
||||||
|
@ -523,10 +528,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
writer = null;
|
writer = null;
|
||||||
|
|
||||||
initState();
|
initState();
|
||||||
|
|
||||||
// Wait for reader and writer threads to be terminated.
|
|
||||||
readerWriterSemaphore.acquireUninterruptibly(2);
|
|
||||||
readerWriterSemaphore.release(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -860,6 +861,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
|
|
||||||
protected class PacketReader {
|
protected class PacketReader {
|
||||||
|
|
||||||
|
private final String threadName = "Smack Reader (" + getConnectionCounter() + ')';
|
||||||
|
|
||||||
XmlPullParser parser;
|
XmlPullParser parser;
|
||||||
|
|
||||||
private volatile boolean done;
|
private volatile boolean done;
|
||||||
|
@ -874,13 +877,15 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
LOGGER.finer(threadName + " start");
|
||||||
try {
|
try {
|
||||||
parsePackets();
|
parsePackets();
|
||||||
} finally {
|
} finally {
|
||||||
|
LOGGER.finer(threadName + " exit");
|
||||||
XMPPTCPConnection.this.readerWriterSemaphore.release();
|
XMPPTCPConnection.this.readerWriterSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "Smack Reader (" + getConnectionCounter() + ")");
|
}, threadName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1128,6 +1133,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
protected class PacketWriter {
|
protected class PacketWriter {
|
||||||
public static final int QUEUE_SIZE = XMPPTCPConnection.QUEUE_SIZE;
|
public static final int QUEUE_SIZE = XMPPTCPConnection.QUEUE_SIZE;
|
||||||
|
|
||||||
|
private final String threadName = "Smack Writer (" + getConnectionCounter() + ')';
|
||||||
|
|
||||||
private final ArrayBlockingQueueWithShutdown<Element> queue = new ArrayBlockingQueueWithShutdown<>(
|
private final ArrayBlockingQueueWithShutdown<Element> queue = new ArrayBlockingQueueWithShutdown<>(
|
||||||
QUEUE_SIZE, true);
|
QUEUE_SIZE, true);
|
||||||
|
|
||||||
|
@ -1173,13 +1180,15 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
LOGGER.finer(threadName + " start");
|
||||||
try {
|
try {
|
||||||
writePackets();
|
writePackets();
|
||||||
} finally {
|
} finally {
|
||||||
|
LOGGER.finer(threadName + " exit");
|
||||||
XMPPTCPConnection.this.readerWriterSemaphore.release();
|
XMPPTCPConnection.this.readerWriterSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "Smack Writer (" + getConnectionCounter() + ")");
|
}, threadName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean done() {
|
private boolean done() {
|
||||||
|
|
Loading…
Reference in a new issue