307 SelectionKeyImpl sk) { |
307 SelectionKeyImpl sk) { |
308 int intOps = sk.nioInterestOps(); // Do this just once, it synchronizes |
308 int intOps = sk.nioInterestOps(); // Do this just once, it synchronizes |
309 int oldOps = sk.nioReadyOps(); |
309 int oldOps = sk.nioReadyOps(); |
310 int newOps = initialOps; |
310 int newOps = initialOps; |
311 |
311 |
312 if ((ops & PollArrayWrapper.POLLNVAL) != 0) { |
312 if ((ops & Net.POLLNVAL) != 0) { |
313 // This should only happen if this channel is pre-closed while a |
313 // This should only happen if this channel is pre-closed while a |
314 // selection operation is in progress |
314 // selection operation is in progress |
315 // ## Throw an error if this channel has not been pre-closed |
315 // ## Throw an error if this channel has not been pre-closed |
316 return false; |
316 return false; |
317 } |
317 } |
318 |
318 |
319 if ((ops & (PollArrayWrapper.POLLERR |
319 if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { |
320 | PollArrayWrapper.POLLHUP)) != 0) { |
|
321 newOps = intOps; |
320 newOps = intOps; |
322 sk.nioReadyOps(newOps); |
321 sk.nioReadyOps(newOps); |
323 return (newOps & ~oldOps) != 0; |
322 return (newOps & ~oldOps) != 0; |
324 } |
323 } |
325 |
324 |
326 if (((ops & PollArrayWrapper.POLLIN) != 0) && |
325 if (((ops & Net.POLLIN) != 0) && |
327 ((intOps & SelectionKey.OP_ACCEPT) != 0)) |
326 ((intOps & SelectionKey.OP_ACCEPT) != 0)) |
328 newOps |= SelectionKey.OP_ACCEPT; |
327 newOps |= SelectionKey.OP_ACCEPT; |
329 |
328 |
330 sk.nioReadyOps(newOps); |
329 sk.nioReadyOps(newOps); |
331 return (newOps & ~oldOps) != 0; |
330 return (newOps & ~oldOps) != 0; |
367 public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { |
366 public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { |
368 int newOps = 0; |
367 int newOps = 0; |
369 |
368 |
370 // Translate ops |
369 // Translate ops |
371 if ((ops & SelectionKey.OP_ACCEPT) != 0) |
370 if ((ops & SelectionKey.OP_ACCEPT) != 0) |
372 newOps |= PollArrayWrapper.POLLIN; |
371 newOps |= Net.POLLIN; |
373 // Place ops into pollfd array |
372 // Place ops into pollfd array |
374 sk.selector.putEventOps(sk, newOps); |
373 sk.selector.putEventOps(sk, newOps); |
375 } |
374 } |
376 |
375 |
377 public FileDescriptor getFD() { |
376 public FileDescriptor getFD() { |