private int unregisterHandles() { int nHandles = 0; for (;;) { AcceptorOperationFuture request = cancelQueue.poll(); if (request == null) { break; } // close the channels for (SocketAddress socketAddress : request.getLocalAddresses()) { DatagramChannel handle = boundHandles.remove(socketAddress); if (handle == null) { continue; } try { close(handle); wakeup(); // wake up again to trigger thread death } catch (Exception e) { ExceptionMonitor.getInstance().exceptionCaught(e); } finally { nHandles++; } } request.setDone(); } return nHandles; }
protected DatagramChannel open(SocketAddress localAddress) throws Exception { final DatagramChannel ch = DatagramChannel.open(); boolean success = false; try { new NioDatagramSessionConfig(ch).setAll(getSessionConfig()); ch.configureBlocking(false); try { ch.socket().bind(localAddress); } catch (IOException ioe) { // Add some info regarding the address we try to bind to the // message String newMessage = "Error while binding on " + localAddress + "\n" + "original message : " + ioe.getMessage(); Exception e = new IOException(newMessage); e.initCause(ioe.getCause()); // And close the channel ch.close(); throw e; } ch.register(selector, SelectionKey.OP_READ); success = true; } finally { if (!success) { close(ch); } } return ch; }
protected DatagramChannel open(SocketAddress localAddress) throws Exception { final DatagramChannel ch = DatagramChannel.open(); boolean success = false; try { new NioDatagramSessionConfig(ch).setAll(getSessionConfig()); ch.configureBlocking(false); try { ch.socket().bind(localAddress); } catch (IOException ioe) { // Add some info regarding the address we try to bind to the // message String newMessage = "Error while binding on " + localAddress + "\n" + "original message : " + ioe.getMessage(); Exception e = new IOException(newMessage); e.initCause(ioe.getCause()); // And close the channel ch.close(); throw e; } ch.register(selector, SelectionKey.OP_READ); success = true; } finally { if (!success) { close(ch); } } return ch; }
private int unregisterHandles() { int nHandles = 0; for (;;) { AcceptorOperationFuture request = cancelQueue.poll(); if (request == null) { break; } // close the channels for (SocketAddress socketAddress : request.getLocalAddresses()) { DatagramChannel handle = boundHandles.remove(socketAddress); if (handle == null) { continue; } try { close(handle); wakeup(); // wake up again to trigger thread death } catch (Exception e) { ExceptionMonitor.getInstance().exceptionCaught(e); } finally { nHandles++; } } request.setDone(); } return nHandles; }
for (DatagramChannel handle : newHandles.values()) { try { close(handle); } catch (Exception e) { ExceptionMonitor.getInstance().exceptionCaught(e);
for (DatagramChannel handle : newHandles.values()) { try { close(handle); } catch (Exception e) { ExceptionMonitor.getInstance().exceptionCaught(e);
@Override protected DatagramChannel open(SocketAddress localAddress) throws Exception { final DatagramChannel c = DatagramChannel.open(); boolean success = false; try { new NioDatagramSessionConfig(c).setAll(getSessionConfig()); c.configureBlocking(false); c.socket().bind(localAddress); c.register(selector, SelectionKey.OP_READ); success = true; } finally { if (!success) { close(c); } } return c; }