Ignore reading in closing socket

This commit is contained in:
Steveice10 2013-07-25 18:58:45 -07:00
parent e2f325a3f1
commit 9f7e7302a5

View file

@ -56,11 +56,6 @@ public abstract class StandardConnection extends BaseConnection {
*/
private Queue<Packet> packets = new ConcurrentLinkedQueue<Packet>();
/**
* Whether the connection is reading.
*/
private boolean reading = false;
/**
* Whether the connection is writing.
*/
@ -170,7 +165,6 @@ public abstract class StandardConnection extends BaseConnection {
public void run() {
while(isConnected()) {
try {
reading = true;
int opcode = input.readUnsignedByte();
if(opcode < 0) {
continue;
@ -190,8 +184,6 @@ public abstract class StandardConnection extends BaseConnection {
} else if(StandardConnection.this instanceof ServerConnection) {
packet.handleServer((ServerConnection) StandardConnection.this);
}
reading = false;
} catch(EOFException e) {
disconnect("End of Stream");
} catch (Exception e) {
@ -204,8 +196,6 @@ public abstract class StandardConnection extends BaseConnection {
Thread.sleep(2);
} catch (InterruptedException e) {
}
reading = false;
}
}
}
@ -246,12 +236,12 @@ public abstract class StandardConnection extends BaseConnection {
}
/**
* A thread that waits for the connection to finish before closing it.
* A thread that waits for the connection to finish writing before closing it.
*/
private class CloseThread extends Thread {
@Override
public void run() {
while(reading || writing) {
while(writing) {
try {
Thread.sleep(2);
} catch (InterruptedException e) {