- if ((key.interestOps() & SelectionKey.OP_ACCEPT) != 0) {
- if (key.isAcceptable()) {
- SocketChannel chan;
- try {
- chan = ((ServerSocketChannel) key.channel()).accept();
- } catch (IOException ignored) {
- key.cancel();
- continue;
- }
- if (chan == null) continue;
- try {
- Peer peer = setup_socket(chan);
- Result_NonePeerHandleErrorZ res = this.peer_manager.new_inbound_connection(peer.descriptor);
- if (res instanceof Result_NonePeerHandleErrorZ.Result_NonePeerHandleErrorZ_OK) {
- peer.key = chan.register(this.selector, SelectionKey.OP_READ, peer);
- }
- } catch (IOException ignored) { }
- }
- continue; // There is no attachment so the rest of the loop is useless
- }
- Peer peer = (Peer) key.attachment();
- synchronized (peer) {
- peer.block_disconnect_socket = true;
- }