[Opensrf-commits] r1064 - trunk/src/java/org/opensrf/net/xmpp
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Jul 28 13:43:01 EDT 2007
Author: erickson
Date: 2007-07-28 13:41:32 -0400 (Sat, 28 Jul 2007)
New Revision: 1064
Modified:
trunk/src/java/org/opensrf/net/xmpp/XMPPSession.java
Log:
synchronizing the initial xmpp login to prevent thread race condition on authentication
Modified: trunk/src/java/org/opensrf/net/xmpp/XMPPSession.java
===================================================================
--- trunk/src/java/org/opensrf/net/xmpp/XMPPSession.java 2007-07-28 17:38:26 UTC (rev 1063)
+++ trunk/src/java/org/opensrf/net/xmpp/XMPPSession.java 2007-07-28 17:41:32 UTC (rev 1064)
@@ -113,29 +113,33 @@
thread.setDaemon(true);
thread.start();
- /* send the initial jabber message */
- sendConnect();
- reader.waitCoreEvent(10000);
+ synchronized(reader) {
+ /* send the initial jabber message */
+ sendConnect();
+ reader.waitCoreEvent(10000);
+ }
if( reader.getXMPPStreamState() != XMPPReader.XMPPStreamState.CONNECT_RECV )
throw new XMPPException("unable to connect to jabber server");
- /* send the basic auth message */
- sendBasicAuth(); /* XXX add support for other auth mechanisms */
- reader.waitCoreEvent(10000);
- if(!connected())
+ synchronized(reader) {
+ /* send the basic auth message */
+ sendBasicAuth();
+ reader.waitCoreEvent(10000);
+ }
+ if(!connected())
throw new XMPPException("Authentication failed");
}
/** Sends the initial jabber message */
private void sendConnect() {
+ reader.setXMPPStreamState(XMPPReader.XMPPStreamState.CONNECT_SENT);
writer.printf(JABBER_CONNECT, host);
- reader.setXMPPStreamState(XMPPReader.XMPPStreamState.CONNECT_SENT);
}
/** Send the basic auth message */
private void sendBasicAuth() {
+ reader.setXMPPStreamState(XMPPReader.XMPPStreamState.AUTH_SENT);
writer.printf(JABBER_BASIC_AUTH, username, password, resource);
- reader.setXMPPStreamState(XMPPReader.XMPPStreamState.AUTH_SENT);
}
More information about the opensrf-commits
mailing list