< prev index next >

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

Print this page




1048                                  Net.inet6AsByteArray(source));
1049                 } else {
1050                     MembershipKeyImpl.Type4 key4 =
1051                         (MembershipKeyImpl.Type4)key;
1052                     Net.unblock4(fd, key4.groupAddress(), key4.interfaceAddress(),
1053                                  Net.inet4AsInt(source));
1054                 }
1055             } catch (IOException ioe) {
1056                 // should not happen
1057                 throw new AssertionError(ioe);
1058             }
1059         }
1060     }
1061 
1062     protected void implCloseSelectableChannel() throws IOException {
1063         synchronized (stateLock) {
1064             if (state != ST_KILLED)
1065                 nd.preClose(fd);
1066             ResourceManager.afterUdpClose();
1067 
1068             // if member of mulitcast group then invalidate all keys
1069             if (registry != null)
1070                 registry.invalidateAll();
1071 
1072             long th;
1073             if ((th = readerThread) != 0)
1074                 NativeThread.signal(th);
1075             if ((th = writerThread) != 0)
1076                 NativeThread.signal(th);
1077             if (!isRegistered())
1078                 kill();
1079         }
1080     }
1081 
1082     public void kill() throws IOException {
1083         synchronized (stateLock) {
1084             if (state == ST_KILLED)
1085                 return;
1086             if (state == ST_UNINITIALIZED) {
1087                 state = ST_KILLED;
1088                 return;




1048                                  Net.inet6AsByteArray(source));
1049                 } else {
1050                     MembershipKeyImpl.Type4 key4 =
1051                         (MembershipKeyImpl.Type4)key;
1052                     Net.unblock4(fd, key4.groupAddress(), key4.interfaceAddress(),
1053                                  Net.inet4AsInt(source));
1054                 }
1055             } catch (IOException ioe) {
1056                 // should not happen
1057                 throw new AssertionError(ioe);
1058             }
1059         }
1060     }
1061 
1062     protected void implCloseSelectableChannel() throws IOException {
1063         synchronized (stateLock) {
1064             if (state != ST_KILLED)
1065                 nd.preClose(fd);
1066             ResourceManager.afterUdpClose();
1067 
1068             // if member of multicast group then invalidate all keys
1069             if (registry != null)
1070                 registry.invalidateAll();
1071 
1072             long th;
1073             if ((th = readerThread) != 0)
1074                 NativeThread.signal(th);
1075             if ((th = writerThread) != 0)
1076                 NativeThread.signal(th);
1077             if (!isRegistered())
1078                 kill();
1079         }
1080     }
1081 
1082     public void kill() throws IOException {
1083         synchronized (stateLock) {
1084             if (state == ST_KILLED)
1085                 return;
1086             if (state == ST_UNINITIALIZED) {
1087                 state = ST_KILLED;
1088                 return;


< prev index next >