Roll back the interrupt() yet again - 1) it didn't fix the problem we were trying to fix and 2) it was causing problems with logoff.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4968 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Mike Thomas
2008-03-10 17:20:03 +00:00
parent 1076052701
commit 6e0bd68148
@@ -25,8 +25,6 @@ import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
import java.net.ConnectException; import java.net.ConnectException;
@@ -302,21 +300,14 @@ public class BlockingCommunicator extends Communicator
String txt = StringUtil.truncate(String.valueOf(msg), 80, "..."); String txt = StringUtil.truncate(String.valueOf(msg), 80, "...");
Log.info("Whoa, writin' a big one [msg=" + txt + ", size=" + buffer.limit() + "]."); Log.info("Whoa, writin' a big one [msg=" + txt + ", size=" + buffer.limit() + "].");
} }
int wrote = _channel.write(buffer);
try { if (wrote != buffer.limit()) {
int wrote = _channel.write(buffer); Log.warning("Aiya! Couldn't write entire message [msg=" + msg +
if (wrote != buffer.limit()) { ", size=" + buffer.limit() + ", wrote=" + wrote + "].");
Log.warning("Aiya! Couldn't write entire message [msg=" + msg + // } else {
", size=" + buffer.limit() + ", wrote=" + wrote + "]."); // Log.info("Wrote " + wrote + " bytes.");
// } else {
// Log.info("Wrote " + wrote + " bytes.");
}
} catch (ClosedChannelException cce) {
// If we weren't expecting it, throw it on.
if (!_interrupted) {
throw cce;
}
} }
} finally { } finally {
_fout.resetFrame(); _fout.resetFrame();
} }
@@ -475,10 +466,6 @@ public class BlockingCommunicator extends Communicator
// process the message // process the message
processMessage(msg); processMessage(msg);
} catch (ClosedByInterruptException cbie) {
// somebody set up us the bomb! we've been interrupted which means that we're being
// shut down, so we just report it and return from iterate() like a good monkey
Log.debug("Reader thread woken up in time to die.");
} catch (InterruptedIOException iioe) { } catch (InterruptedIOException iioe) {
// somebody set up us the bomb! we've been interrupted which means that we're being // somebody set up us the bomb! we've been interrupted which means that we're being
@@ -518,11 +505,11 @@ public class BlockingCommunicator extends Communicator
{ {
// we want to interrupt the reader thread as it may be blocked listening to the socket; // we want to interrupt the reader thread as it may be blocked listening to the socket;
// this is only called if the reader thread doesn't shut itself down // this is only called if the reader thread doesn't shut itself down
// Note that we're the ones in control of the interruption, and then do it to get our // While it would be nice to be able to handle wacky cases requiring reader-side
// reader out of waiting for the rest of a readFrame if necessary. // shutdown, doing so causes consternation on the other end's writer which suddenly
_interrupted = true; // loses its connection. So, we rely on the writer side to take us down.
interrupt(); // interrupt();
} }
} }
@@ -599,7 +586,4 @@ public class BlockingCommunicator extends Communicator
protected ClientDObjectMgr _omgr; protected ClientDObjectMgr _omgr;
protected ClassLoader _loader; protected ClassLoader _loader;
/** Whether or not we have interrupted our reader. */
protected boolean _interrupted;
} }