public void terminateWrites() throws IOException { if (connection.writeClosed()) try { int state = this.state; if (allAreClear(state, WRITE_SHUTDOWN)) { this.state = state & ~(WRITE_READY | WRITE_WAKEUP | WRITE_RESUMED) | WRITE_SHUTDOWN; if (allAreSet(state, READ_SHUTDOWN)) { terminate(); } else { thread.doResume(this, allAreSet(state, READ_RESUMED), false, true); Native.testAndThrow(Native.shutdown(fd, false, true)); if (Native.EXTRA_TRACE) log.tracef("Shutdown writes(%d)", fd); } } } finally { writeTerminated(); } }