Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long beforeSelect = System.currentTimeMillis();
- int selected = SelectorUtil.select(selector);
- if (selected == 0 && !wakenUp.get()) {
- long timeBlocked = System.currentTimeMillis() - beforeSelect;
- if (timeBlocked < minSelectTimeout) {
- boolean notConnected = false;
- for (SelectionKey key: selector.keys()) {
- AbstractNioChannel<?> ch = (AbstractNioChannel<?>) key.attachment();
- if (!ch.isConnected()) {
- notConnected = true;
- break;
- }
- }
- if (notConnected) {
- selectReturnsImmediately = 0;
- } else {
- // returned before the minSelectTimeout elapsed with nothing select.
- // this may be the cause of the jdk epoll(..) bug, so increment the counter
- // which we use later to see if its really the jdk bug.
- selectReturnsImmediately ++;
- System.out.println("blocked=" + timeBlocked + " min=" + minSelectTimeout
- + "times=" + selectReturnsImmediately);
- }
- } else {
- selectReturnsImmediately = 0;
- }
Add Comment
Please, Sign In to add comment