< prev index next >

src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java

Print this page
*** 133,12 ***
      private static final int ST_CLOSING = 2;
      private static final int ST_CLOSED = 3;
      private int state;
  
      // IDs of native threads doing reads and writes, for signalling
!     private long readerThread;
!     private long writerThread;
  
      // Local and remote (connected) address
      private InetSocketAddress localAddress;
      private InetSocketAddress remoteAddress;
  
--- 133,12 ---
      private static final int ST_CLOSING = 2;
      private static final int ST_CLOSED = 3;
      private int state;
  
      // IDs of native threads doing reads and writes, for signalling
!     private NativeThread readerThread;
!     private NativeThread writerThread;
  
      // Local and remote (connected) address
      private InetSocketAddress localAddress;
      private InetSocketAddress remoteAddress;
  

*** 536,11 ***
      private void endRead(boolean blocking, boolean completed)
          throws AsynchronousCloseException
      {
          if (blocking) {
              synchronized (stateLock) {
!                 readerThread = 0;
                  if (state == ST_CLOSING) {
                      tryFinishClose();
                  }
              }
              if (interruptible) {
--- 536,11 ---
      private void endRead(boolean blocking, boolean completed)
          throws AsynchronousCloseException
      {
          if (blocking) {
              synchronized (stateLock) {
!                 readerThread = null;
                  if (state == ST_CLOSING) {
                      tryFinishClose();
                  }
              }
              if (interruptible) {

*** 1043,11 ***
      private void endWrite(boolean blocking, boolean completed)
          throws AsynchronousCloseException
      {
          if (blocking) {
              synchronized (stateLock) {
!                 writerThread = 0;
                  if (state == ST_CLOSING) {
                      tryFinishClose();
                  }
              }
  
--- 1043,11 ---
      private void endWrite(boolean blocking, boolean completed)
          throws AsynchronousCloseException
      {
          if (blocking) {
              synchronized (stateLock) {
!                 writerThread = null;
                  if (state == ST_CLOSING) {
                      tryFinishClose();
                  }
              }
  

*** 1712,11 ***
       * Closes the socket if there are no I/O operations in progress and the
       * channel is not registered with a Selector.
       */
      private boolean tryClose() throws IOException {
          assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
!         if ((readerThread == 0) && (writerThread == 0) && !isRegistered()) {
              state = ST_CLOSED;
              try {
                  // close socket
                  cleaner.clean();
              } catch (UncheckedIOException ioe) {
--- 1712,11 ---
       * Closes the socket if there are no I/O operations in progress and the
       * channel is not registered with a Selector.
       */
      private boolean tryClose() throws IOException {
          assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
!         if ((readerThread == null) && (writerThread == null) && !isRegistered()) {
              state = ST_CLOSED;
              try {
                  // close socket
                  cleaner.clean();
              } catch (UncheckedIOException ioe) {
< prev index next >