319 SelectionKeyImpl sk) { |
319 SelectionKeyImpl sk) { |
320 int intOps = sk.nioInterestOps(); |
320 int intOps = sk.nioInterestOps(); |
321 int oldOps = sk.nioReadyOps(); |
321 int oldOps = sk.nioReadyOps(); |
322 int newOps = initialOps; |
322 int newOps = initialOps; |
323 |
323 |
324 if ((ops & PollArrayWrapper.POLLNVAL) != 0) { |
324 if ((ops & Net.POLLNVAL) != 0) { |
325 /* This should only happen if this channel is pre-closed while a |
325 /* This should only happen if this channel is pre-closed while a |
326 * selection operation is in progress |
326 * selection operation is in progress |
327 * ## Throw an error if this channel has not been pre-closed */ |
327 * ## Throw an error if this channel has not been pre-closed */ |
328 return false; |
328 return false; |
329 } |
329 } |
330 |
330 |
331 if ((ops & (PollArrayWrapper.POLLERR |
331 if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { |
332 | PollArrayWrapper.POLLHUP)) != 0) { |
|
333 newOps = intOps; |
332 newOps = intOps; |
334 sk.nioReadyOps(newOps); |
333 sk.nioReadyOps(newOps); |
335 return (newOps & ~oldOps) != 0; |
334 return (newOps & ~oldOps) != 0; |
336 } |
335 } |
337 |
336 |
338 if (((ops & PollArrayWrapper.POLLIN) != 0) && |
337 if (((ops & Net.POLLIN) != 0) && |
339 ((intOps & SelectionKey.OP_READ) != 0)) |
338 ((intOps & SelectionKey.OP_READ) != 0)) |
340 newOps |= SelectionKey.OP_READ; |
339 newOps |= SelectionKey.OP_READ; |
341 |
340 |
342 if (((ops & PollArrayWrapper.POLLOUT) != 0) && |
341 if (((ops & Net.POLLOUT) != 0) && |
343 ((intOps & SelectionKey.OP_WRITE) != 0)) |
342 ((intOps & SelectionKey.OP_WRITE) != 0)) |
344 newOps |= SelectionKey.OP_WRITE; |
343 newOps |= SelectionKey.OP_WRITE; |
345 |
344 |
346 sk.nioReadyOps(newOps); |
345 sk.nioReadyOps(newOps); |
347 return (newOps & ~oldOps) != 0; |
346 return (newOps & ~oldOps) != 0; |
359 |
358 |
360 @Override |
359 @Override |
361 public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { |
360 public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { |
362 int newOps = 0; |
361 int newOps = 0; |
363 if ((ops & SelectionKey.OP_READ) != 0) |
362 if ((ops & SelectionKey.OP_READ) != 0) |
364 newOps |= PollArrayWrapper.POLLIN; |
363 newOps |= Net.POLLIN; |
365 if ((ops & SelectionKey.OP_WRITE) != 0) |
364 if ((ops & SelectionKey.OP_WRITE) != 0) |
366 newOps |= PollArrayWrapper.POLLOUT; |
365 newOps |= Net.POLLOUT; |
367 sk.selector.putEventOps(sk, newOps); |
366 sk.selector.putEventOps(sk, newOps); |
368 } |
367 } |
369 |
368 |
370 @Override |
369 @Override |
371 public void kill() throws IOException { |
370 public void kill() throws IOException { |