Make sure our socket connection is closed if authentication fails.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2399 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Communicator.java,v 1.27 2003/01/21 05:27:48 mdb Exp $
|
// $Id: Communicator.java,v 1.28 2003/04/10 22:02:59 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.client;
|
package com.threerings.presents.client;
|
||||||
|
|
||||||
@@ -235,8 +235,12 @@ public class Communicator
|
|||||||
// clear out our reader reference
|
// clear out our reader reference
|
||||||
_reader = null;
|
_reader = null;
|
||||||
|
|
||||||
// let the client know when we finally go away
|
|
||||||
if (_writer == null) {
|
if (_writer == null) {
|
||||||
|
// there's no writer during authentication, so we may be
|
||||||
|
// responsible for closing the socket channel
|
||||||
|
closeChannel();
|
||||||
|
|
||||||
|
// let the client know when we finally go away
|
||||||
_client.communicatorDidExit();
|
_client.communicatorDidExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,22 +256,13 @@ public class Communicator
|
|||||||
_writer = null;
|
_writer = null;
|
||||||
Log.debug("Writer thread exited.");
|
Log.debug("Writer thread exited.");
|
||||||
|
|
||||||
|
// let the client observers know that we're logged off
|
||||||
|
_client.notifyObservers(Client.CLIENT_DID_LOGOFF, null);
|
||||||
|
|
||||||
// now that the writer thread has gone away, we can safely close
|
// now that the writer thread has gone away, we can safely close
|
||||||
// our socket and let the client know that the logoff process has
|
// our socket and let the client know that the logoff process has
|
||||||
// completed
|
// completed
|
||||||
try {
|
closeChannel();
|
||||||
_channel.close();
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
Log.warning("Error closing failed socket: " + ioe);
|
|
||||||
}
|
|
||||||
_channel = null;
|
|
||||||
|
|
||||||
// clear these out because they are probably large and in charge
|
|
||||||
_oin = null;
|
|
||||||
_oout = null;
|
|
||||||
|
|
||||||
// let the client observers know that we're logged off
|
|
||||||
_client.notifyObservers(Client.CLIENT_DID_LOGOFF, null);
|
|
||||||
|
|
||||||
// let the client know when we finally go away
|
// let the client know when we finally go away
|
||||||
if (_reader == null) {
|
if (_reader == null) {
|
||||||
@@ -275,6 +270,29 @@ public class Communicator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the socket channel that we have open to the server. Called
|
||||||
|
* by either {@link #readerDidExit} or {@link #writerDidExit}
|
||||||
|
* whichever is called last.
|
||||||
|
*/
|
||||||
|
protected void closeChannel ()
|
||||||
|
{
|
||||||
|
if (_channel != null) {
|
||||||
|
Log.debug("Closing socket channel.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
_channel.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
Log.warning("Error closing failed socket: " + ioe);
|
||||||
|
}
|
||||||
|
_channel = null;
|
||||||
|
|
||||||
|
// clear these out because they are probably large and in charge
|
||||||
|
_oin = null;
|
||||||
|
_oout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the supplied message to the socket.
|
* Writes the supplied message to the socket.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user