maintain own ishut status

This commit is contained in:
Greg Wilkins 2011-11-16 13:15:36 +11:00
parent 9ac9a1d687
commit a9d33bb561
2 changed files with 31 additions and 22 deletions

View File

@ -215,6 +215,8 @@ public class ChannelEndPoint implements EndPoint
*/
public int fill(Buffer buffer) throws IOException
{
if (_ishut)
return -1;
Buffer buf = buffer.buffer();
int len=0;
if (buf instanceof NIOBuffer)

View File

@ -160,34 +160,41 @@ public class IOTest
// Client reads response
assertEquals(1,client.getInputStream().read());
// Client reads -1 and does ishut
assertEquals(-1,client.getInputStream().read());
assertFalse(client.isInputShutdown());
System.err.println("ISHUT "+client);
client.shutdownInput();
// Client ???
System.err.println("OSHUT "+client);
client.shutdownOutput();
System.err.println("CLOSE "+client);
client.close();
// Server reads -1, does ishut and then close
assertEquals(-1,server.getInputStream().read());
assertFalse(server.isInputShutdown());
System.err.println("ISHUT "+server);
try
{
server.shutdownInput();
// Client reads -1 and does ishut
assertEquals(-1,client.getInputStream().read());
assertFalse(client.isInputShutdown());
System.err.println("ISHUT "+client);
client.shutdownInput();
// Client ???
System.err.println("OSHUT "+client);
client.shutdownOutput();
System.err.println("CLOSE "+client);
client.close();
// Server reads -1, does ishut and then close
assertEquals(-1,server.getInputStream().read());
assertFalse(server.isInputShutdown());
System.err.println("ISHUT "+server);
try
{
server.shutdownInput();
}
catch(SocketException e)
{
System.err.println(e);
}
System.err.println("CLOSE "+server);
server.close();
}
catch(SocketException e)
catch(Exception e)
{
System.err.println(e);
}
System.err.println("CLOSE "+server);
server.close();
}
@Test