< prev index next >

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

Print this page
*** 132,13 ***
      private static final int ST_CONNECTED = 1;
      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;
  
--- 132,13 ---
      private static final int ST_CONNECTED = 1;
      private static final int ST_CLOSING = 2;
      private static final int ST_CLOSED = 3;
      private int state;
  
!     // Threads doing reads and writes, for signalling
!     private Thread readerThread;
!     private Thread writerThread;
  
      // Local and remote (connected) address
      private InetSocketAddress localAddress;
      private InetSocketAddress remoteAddress;
  

*** 521,11 ***
              if ((remote == null) && mustBeConnected)
                  throw new NotYetConnectedException();
              if (localAddress == null)
                  bindInternal(null);
              if (blocking)
!                 readerThread = NativeThread.current();
          }
          return remote;
      }
  
      /**
--- 521,11 ---
              if ((remote == null) && mustBeConnected)
                  throw new NotYetConnectedException();
              if (localAddress == null)
                  bindInternal(null);
              if (blocking)
!                 readerThread = NativeThread.threadToSignal();
          }
          return remote;
      }
  
      /**

*** 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) {

*** 1028,11 ***
              if ((remote == null) && mustBeConnected)
                  throw new NotYetConnectedException();
              if (localAddress == null)
                  bindInternal(null);
              if (blocking)
!                 writerThread = NativeThread.current();
          }
          return remote;
      }
  
      /**
--- 1028,11 ---
              if ((remote == null) && mustBeConnected)
                  throw new NotYetConnectedException();
              if (localAddress == null)
                  bindInternal(null);
              if (blocking)
!                 writerThread = NativeThread.threadToSignal();
          }
          return remote;
      }
  
      /**

*** 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 >