@Override public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel();
@Override public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel();
public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel();
if (processSocket(ka.getChannel(), status, true)) { return; // don't close on comet timeout processSocket(ka.getChannel(), status, false); //don't dispatch if the lines below are cancelling the key
reg(key,ka,0);//avoid multiple calls, this gets reregistered after invokation if (!processSocket(ka.getChannel(), SocketStatus.OPEN)) processSocket(ka.getChannel(), SocketStatus.DISCONNECT); }else if ((ka.interestOps()&SelectionKey.OP_READ) == SelectionKey.OP_READ || (ka.interestOps()&SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
NioChannel channel = attachment.getChannel(); if (sk.isReadable() || sk.isWritable() ) { if ( attachment.getSendfileData() != null ) {
NioChannel channel = attachment.getChannel(); if (sk.isReadable() || sk.isWritable() ) { if ( attachment.getSendfileData() != null ) {
if (processSocket(ka.getChannel(), status, true)) { return; // don't close on comet timeout processSocket(ka.getChannel(), status, false); //don't dispatch if the lines below are cancelling the key
NioChannel channel = attachment.getChannel(); if (sk.isReadable() || sk.isWritable() ) { if ( attachment.getSendfileData() != null ) {
if (processSocket(ka.getChannel(), status, true)) { return; // don't close on comet timeout processSocket(ka.getChannel(), status, false); //don't dispatch if the lines below are cancelling the key if (ka!=null) handler.release(ka.getChannel()); else handler.release((SocketChannel)key.channel()); if (key.isValid()) key.cancel();
NioChannel channel = attachment.getChannel(); if (sk.isReadable() || sk.isWritable() ) { if ( attachment.getSendfileData() != null ) {
} else if ( sk.isValid() && attachment != null ) { NioChannel channel = attachment.getChannel(); if (sk.isReadable() || sk.isWritable() ) { if ( attachment.getSendfileData() != null ) {
public void remove(final KeyAttachment key, final int ops) { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; final SocketChannel ch = nch.getIOChannel();
@Override public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel();
public void cancelledKey(SelectionKey key, SocketStatus status, boolean dispatch) { try { if ( key == null ) return;//nothing to do KeyAttachment ka = (KeyAttachment) key.attachment(); if (ka != null && ka.getComet() && status != null) { //the comet event takes care of clean up //processSocket(ka.getChannel(), status, dispatch); ka.setComet(false);//to avoid a loop if (status == SocketStatus.TIMEOUT ) { processSocket(ka.getChannel(), status, true); return; // don't close on comet timeout } else { processSocket(ka.getChannel(), status, false); //don't dispatch if the lines below are cancelling the key } } key.attach(null); if (ka!=null) handler.release(ka.getChannel()); if (key.isValid()) key.cancel(); if (key.channel().isOpen()) try {key.channel().close();}catch (Exception ignore){} try {if (ka!=null) ka.channel.close(true);}catch (Exception ignore){} try {if (ka!=null && ka.getSendfileData()!=null && ka.getSendfileData().fchannel!=null && ka.getSendfileData().fchannel.isOpen()) ka.getSendfileData().fchannel.close();}catch (Exception ignore){} if (ka!=null) ka.reset(); } catch (Throwable e) { if ( log.isDebugEnabled() ) log.error("",e); // Ignore } } /**
public void add(final KeyAttachment key, final int ops, final KeyReference ref) { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; final SocketChannel ch = nch.getIOChannel(); if ( ch == null ) return; Runnable r = new Runnable() { @Override public void run() { SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { sk = ch.register(selector, ops, key); ref.key = sk; } else if (!sk.isValid()) { cancel(sk,key,ops); } else { sk.interestOps(sk.interestOps() | ops); } }catch (CancelledKeyException cx) { cancel(sk,key,ops); }catch (ClosedChannelException cx) { cancel(sk,key,ops); } } }; events.offer(r); wakeup(); }
@Override public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel(); if ( ch == null ) return; SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { sk = ch.register(selector, ops, key); ref.key = sk; } else if (!sk.isValid()) { cancel(sk,key,ops); } else { sk.interestOps(sk.interestOps() | ops); } }catch (CancelledKeyException cx) { cancel(sk,key,ops); }catch (ClosedChannelException cx) { cancel(sk,key,ops); } } };
public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel(); if ( ch == null ) return; SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { sk = ch.register(selector, ops, key); ref.key = sk; } else if (!sk.isValid()) { cancel(sk,key,ops); } else { sk.interestOps(sk.interestOps() | ops); } }catch (CancelledKeyException cx) { cancel(sk,key,ops); }catch (ClosedChannelException cx) { cancel(sk,key,ops); } } };
@Override public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel(); if ( ch == null ) return; SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { sk = ch.register(selector, ops, key); ref.key = sk; } else if (!sk.isValid()) { cancel(sk,key,ops); } else { sk.interestOps(sk.interestOps() | ops); } }catch (CancelledKeyException cx) { cancel(sk,key,ops); }catch (ClosedChannelException cx) { cancel(sk,key,ops); } } };
@Override public void run() { if ( key == null ) return; NioChannel nch = key.getChannel(); if ( nch == null ) return; SocketChannel ch = nch.getIOChannel(); if ( ch == null ) return; SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { sk = ch.register(selector, ops, key); ref.key = sk; } else if (!sk.isValid()) { cancel(sk,key,ops); } else { sk.interestOps(sk.interestOps() | ops); } }catch (CancelledKeyException cx) { cancel(sk,key,ops); }catch (ClosedChannelException cx) { cancel(sk,key,ops); } } };