1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-30 02:02:06 +01:00

SMACK-384 Don't use a semaphore while waiting for PacketReader to be started.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_0@13577 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-03-22 18:14:08 +00:00 committed by flow
parent b091f6161e
commit 57a5f88ead

View file

@ -51,7 +51,6 @@ class PacketReader {
volatile boolean done;
private String connectionID = null;
private Semaphore connectionSemaphore;
protected PacketReader(final XMPPConnection connection) {
this.connection = connection;
@ -97,21 +96,17 @@ class PacketReader {
* @throws XMPPException if the server fails to send an opening stream back
* for more than five seconds.
*/
public void startup() throws XMPPException {
connectionSemaphore = new Semaphore(1);
synchronized public void startup() throws XMPPException {
readerThread.start();
// Wait for stream tag before returing. We'll wait a couple of seconds before
// Wait for stream tag before returning. We'll wait a couple of seconds before
// giving up and throwing an error.
try {
connectionSemaphore.acquire();
// A waiting thread may be woken up before the wait time or a notify
// (although this is a rare thing). Therefore, we continue waiting
// until either a connectionID has been set (and hence a notify was
// made) or the total wait time has elapsed.
int waitTime = SmackConfiguration.getPacketReplyTimeout();
connectionSemaphore.tryAcquire(3 * waitTime, TimeUnit.MILLISECONDS);
wait(3 * waitTime);
}
catch (InterruptedException ie) {
// Ignore.
@ -304,8 +299,8 @@ class PacketReader {
* 3) TLS negotiation was successful
*
*/
private void releaseConnectionIDLock() {
connectionSemaphore.release();
synchronized private void releaseConnectionIDLock() {
notify();
}
/**