< prev index next >

src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java

Print this page
*** 79,13 ***
  
      private final FileDescriptor fd;
  
      private final int fdVal;
  
!     /* IDs of native threads doing send and receives, for signalling */
!     private volatile long receiverThread;
!     private volatile long senderThread;
  
      /* Lock held by current receiving thread */
      private final Object receiveLock = new Object();
  
      /* Lock held by current sending thread */
--- 79,13 ---
  
      private final FileDescriptor fd;
  
      private final int fdVal;
  
!     /* Threads doing send and receives, for signalling */
!     private volatile Thread receiverThread;
!     private volatile Thread senderThread;
  
      /* Lock held by current receiving thread */
      private final Object receiveLock = new Object();
  
      /* Lock held by current sending thread */

*** 263,19 ***
          }
      }
  
      private void receiverCleanup() throws IOException {
          synchronized (stateLock) {
!             receiverThread = 0;
              if (state == ChannelState.KILLPENDING)
                  kill();
          }
      }
  
      private void senderCleanup() throws IOException {
          synchronized (stateLock) {
!             senderThread = 0;
              if (state == ChannelState.KILLPENDING)
                  kill();
          }
      }
  
--- 263,19 ---
          }
      }
  
      private void receiverCleanup() throws IOException {
          synchronized (stateLock) {
!             receiverThread = null;
              if (state == ChannelState.KILLPENDING)
                  kill();
          }
      }
  
      private void senderCleanup() throws IOException {
          synchronized (stateLock) {
!             senderThread = null;
              if (state == ChannelState.KILLPENDING)
                  kill();
          }
      }
  

*** 288,14 ***
      public void implCloseSelectableChannel() throws IOException {
          synchronized (stateLock) {
              if (state != ChannelState.KILLED)
                  SctpNet.preClose(fdVal);
  
!             if (receiverThread != 0)
                  NativeThread.signal(receiverThread);
  
!             if (senderThread != 0)
                  NativeThread.signal(senderThread);
  
              if (!isRegistered())
                  kill();
          }
--- 288,14 ---
      public void implCloseSelectableChannel() throws IOException {
          synchronized (stateLock) {
              if (state != ChannelState.KILLED)
                  SctpNet.preClose(fdVal);
  
!             if (receiverThread != null)
                  NativeThread.signal(receiverThread);
  
!             if (senderThread != null)
                  NativeThread.signal(senderThread);
  
              if (!isRegistered())
                  kill();
          }

*** 376,11 ***
                  return;
              }
              assert !isOpen() && !isRegistered();
  
              /* Postpone the kill if there is a thread sending or receiving. */
!             if (receiverThread == 0 && senderThread == 0) {
                  state = ChannelState.KILLED;
                  SctpNet.close(fdVal);
              } else {
                  state = ChannelState.KILLPENDING;
              }
--- 376,11 ---
                  return;
              }
              assert !isOpen() && !isRegistered();
  
              /* Postpone the kill if there is a thread sending or receiving. */
!             if (receiverThread == null && senderThread == null) {
                  state = ChannelState.KILLED;
                  SctpNet.close(fdVal);
              } else {
                  state = ChannelState.KILLPENDING;
              }

*** 482,11 ***
                          begin();
  
                          synchronized (stateLock) {
                              if(!isOpen())
                                  return null;
!                             receiverThread = NativeThread.current();
                          }
  
                          do {
                              n = receive(fdVal, buffer, resultContainer);
                          } while ((n == IOStatus.INTERRUPTED) && isOpen());
--- 482,11 ---
                          begin();
  
                          synchronized (stateLock) {
                              if(!isOpen())
                                  return null;
!                             receiverThread = NativeThread.threadToSignal();
                          }
  
                          do {
                              n = receive(fdVal, buffer, resultContainer);
                          } while ((n == IOStatus.INTERRUPTED) && isOpen());

*** 763,11 ***
                  begin();
  
                  synchronized (stateLock) {
                      if(!isOpen())
                          return 0;
!                     senderThread = NativeThread.current();
  
                      /* Determine what address or association to send to */
                      Association assoc = messageInfo.association();
                      InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
                      if (assoc != null) {
--- 763,11 ---
                  begin();
  
                  synchronized (stateLock) {
                      if(!isOpen())
                          return 0;
!                     senderThread = NativeThread.threadToSignal();
  
                      /* Determine what address or association to send to */
                      Association assoc = messageInfo.association();
                      InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
                      if (assoc != null) {
< prev index next >