< prev index next >

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

Print this page
@@ -106,12 +106,12 @@
  
      // set to true when the socket is in non-blocking mode
      private volatile boolean nonBlocking;
  
      // used by connect/read/write/accept, protected by stateLock
-     private long readerThread;
-     private long writerThread;
+     private NativeThread readerThread;
+     private NativeThread writerThread;
  
      // used when SO_REUSEADDR is emulated, protected by stateLock
      private boolean isReuseAddress;
  
      // read or accept timeout in millis

@@ -232,11 +232,11 @@
       * Marks the end of a read operation that may have blocked.
       * @throws SocketException is the socket is closed
       */
      private void endRead(boolean completed) throws SocketException {
          synchronized (stateLock) {
-             readerThread = 0;
+             readerThread = null;
              int state = this.state;
              if (state == ST_CLOSING)
                  tryFinishClose();
              if (!completed && state >= ST_CLOSING)
                  throw new SocketException("Socket closed");

@@ -377,11 +377,11 @@
       * Marks the end of a write operation that may have blocked.
       * @throws SocketException is the socket is closed
       */
      private void endWrite(boolean completed) throws SocketException {
          synchronized (stateLock) {
-             writerThread = 0;
+             writerThread = null;
              int state = this.state;
              if (state == ST_CLOSING)
                  tryFinishClose();
              if (!completed && state >= ST_CLOSING)
                  throw new SocketException("Socket closed");

@@ -519,11 +519,11 @@
       * Marks the end of a connect operation that may have blocked.
       * @throws SocketException is the socket is closed
       */
      private void endConnect(FileDescriptor fd, boolean completed) throws IOException {
          synchronized (stateLock) {
-             readerThread = 0;
+             readerThread = null;
              int state = this.state;
              if (state == ST_CLOSING)
                  tryFinishClose();
              if (completed && state == ST_CONNECTING) {
                  this.state = ST_CONNECTED;

@@ -676,11 +676,11 @@
       * @throws SocketException is the socket is closed
       */
      private void endAccept(boolean completed) throws SocketException {
          synchronized (stateLock) {
              int state = this.state;
-             readerThread = 0;
+             readerThread = null;
              if (state == ST_CLOSING)
                  tryFinishClose();
              if (!completed && state >= ST_CLOSING)
                  throw new SocketException("Socket closed");
          }

@@ -842,11 +842,11 @@
      /**
       * Closes the socket if there are no I/O operations in progress.
       */
      private boolean tryClose() throws IOException {
          assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
-         if (readerThread == 0 && writerThread == 0) {
+         if (readerThread == null && writerThread == null) {
              try {
                  cleaner.clean();
              } catch (UncheckedIOException ioe) {
                  throw ioe.getCause();
              } finally {

@@ -1142,11 +1142,11 @@
          synchronized (stateLock) {
              ensureOpenAndConnected();
              if (!isInputClosed) {
                  Net.shutdown(fd, Net.SHUT_RD);
                  if (NativeThread.isVirtualThread(readerThread)) {
-                     Poller.stopPoll(fdVal(fd), Net.POLLIN);
+                     Poller.stopPoll(readerThread.thread());
                  }
                  isInputClosed = true;
              }
          }
      }

@@ -1156,11 +1156,11 @@
          synchronized (stateLock) {
              ensureOpenAndConnected();
              if (!isOutputClosed) {
                  Net.shutdown(fd, Net.SHUT_WR);
                  if (NativeThread.isVirtualThread(writerThread)) {
-                     Poller.stopPoll(fdVal(fd), Net.POLLOUT);
+                     Poller.stopPoll(writerThread.thread());
                  }
                  isOutputClosed = true;
              }
          }
      }
< prev index next >