Refine search
private static void bind( OioClientSocketChannel channel, ChannelFuture future, SocketAddress localAddress) { try { channel.socket.bind(localAddress); future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { future.setSuccess(); } else { future.setFailure(f.getCause()); } } });
final int size = futures.size(); for (int i = 0; i < size; i ++) { futures.get(i).setFailure(cause); fireExceptionCaught(ctx, cause);
static void disconnect(OioDatagramChannel channel, ChannelFuture future) { boolean connected = channel.isConnected(); boolean iothread = isIoThread(channel); try { channel.socket.disconnect(); future.setSuccess(); if (connected) { // Notify. if (iothread) { fireChannelDisconnected(channel); } else { fireChannelDisconnectedLater(channel); } } } catch (Throwable t) { future.setFailure(t); if (iothread) { fireExceptionCaught(channel, t); } else { fireExceptionCaughtLater(channel, t); } } } }
private void discard(ChannelHandlerContext ctx, boolean fireNow) { ClosedChannelException cause = null; for (;;) { MessageEvent currentEvent = this.currentEvent; if (this.currentEvent == null) { currentEvent = queue.poll(); } else { this.currentEvent = null; } if (currentEvent == null) { break; } Object m = currentEvent.getMessage(); if (m instanceof ChunkedInput) { closeInput((ChunkedInput) m); } // Trigger a ClosedChannelException if (cause == null) { cause = new ClosedChannelException(); } currentEvent.getFuture().setFailure(cause); } if (cause != null) { if (fireNow) { fireExceptionCaught(ctx.getChannel(), cause); } else { fireExceptionCaughtLater(ctx.getChannel(), cause); } } }
private static void bind( NioClientSocketChannel channel, ChannelFuture future, SocketAddress localAddress) { try { channel.channel.socket().bind(localAddress); channel.boundManually = true; channel.setBound(); future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
public void operationComplete(ChannelFuture cf) throws Exception { if (cf.isSuccess()) { future.setSuccess(); } else { future.setFailure(cf.getCause()); } } }
static void disconnect(NioDatagramChannel channel, ChannelFuture future) { boolean connected = channel.isConnected(); boolean iothread = isIoThread(channel); try { channel.getDatagramChannel().disconnect(); future.setSuccess(); if (connected) { if (iothread) { fireChannelDisconnected(channel); } else { fireChannelDisconnectedLater(channel); } } } catch (Throwable t) { future.setFailure(t); if (iothread) { fireExceptionCaught(channel, t); } else { fireExceptionCaughtLater(channel, t); } } }
/** * Fail all buffered writes that are left. See * <a href="https://github.com/netty/netty/issues/308>#308</a> for more details. */ @Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Throwable cause = null; for (;;) { MessageEvent ev = queue.poll(); if (ev == null) { break; } if (cause == null) { cause = new ClosedChannelException(); } ev.getFuture().setFailure(cause); } if (cause != null) { Channels.fireExceptionCaught(ctx.getChannel(), cause); } super.channelClosed(ctx, e); }
future.setFailure(cause); fireExceptionCaught = true; evt.getFuture().setFailure(cause); fireExceptionCaught(channel, cause); } else { fireExceptionCaughtLater(channel, cause);
private static void close(OioServerSocketChannel channel, ChannelFuture future) { boolean bound = channel.isBound(); try { channel.socket.close(); // Make sure the boss thread is not running so that that the future // is notified after a new connection cannot be accepted anymore. // See NETTY-256 for more information. channel.shutdownLock.lock(); try { if (channel.setClosed()) { future.setSuccess(); if (bound) { fireChannelUnbound(channel); } fireChannelClosed(channel); } else { future.setSuccess(); } } finally { channel.shutdownLock.unlock(); } } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { future.setSuccess(); } else { future.setFailure(f.getCause()); } } });
fireWriteCompleteLater(channel, length); future.setSuccess(); } catch (Throwable t) { future.setFailure(t); if (iothread) { fireExceptionCaught(channel, t); } else { fireExceptionCaughtLater(channel, t);
private void processSelectedKeys(Set<SelectionKey> selectedKeys) { // check if the set is empty and if so just return to not create garbage by // creating a new Iterator every time even if there is nothing to process. // See https://github.com/netty/netty/issues/597 if (selectedKeys.isEmpty()) { return; } for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) { SelectionKey k = i.next(); i.remove(); if (!k.isValid()) { close(k); continue; } try { if (k.isConnectable()) { connect(k); } } catch (Throwable t) { NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment(); ch.connectFuture.setFailure(t); fireExceptionCaught(ch, t); k.cancel(); // Some JDK implementations run into an infinite loop without this. ch.worker.close(ch, succeededFuture(ch)); } } }
this.currentEvent = null; currentEvent.getFuture().setFailure(t); if (fireNow) { fireExceptionCaught(ctx, t); } else { fireExceptionCaughtLater(ctx, t);
private static void close(DefaultLocalServerChannel channel, ChannelFuture future) { try { if (channel.setClosed()) { future.setSuccess(); LocalAddress localAddress = channel.localAddress; if (channel.bound.compareAndSet(true, false)) { channel.localAddress = null; LocalChannelRegistry.unregister(localAddress); fireChannelUnbound(channel); } fireChannelClosed(channel); } else { future.setSuccess(); } } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } } }
public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { future.setSuccess(); if (size != 0) { fireWriteComplete(HttpTunnelingClientSocketChannel.this, size); } } else { future.setFailure(f.getCause()); } } });
if (out == null) { Exception e = new ClosedChannelException(); future.setFailure(e); if (iothread) { fireExceptionCaught(channel, e); } else { fireExceptionCaughtLater(channel, e); future.setSuccess(); if (iothread) { fireWriteComplete(channel, length); t = new ClosedChannelException(); future.setFailure(t); if (iothread) { fireExceptionCaught(channel, t); } else { fireExceptionCaughtLater(channel, t);
public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { Throwable cause = future.getCause(); hsFuture.setFailure(cause); fireExceptionCaught(ctx, cause); if (closeOnSslException) { Channels.close(ctx, future(channel)); } } } });
public void run() { boolean bound = false; boolean registered = false; try { channel.socket.socket().bind(localAddress, channel.getConfig().getBacklog()); bound = true; future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); channel.socket.register(selector, SelectionKey.OP_ACCEPT, channel); registered = true; } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } finally { if (!registered && bound) { close(channel, future); } } } }