Guest User

Untitled

a guest
Dec 14th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. long beforeSelect = System.currentTimeMillis();
  2. int selected = SelectorUtil.select(selector);
  3. if (selected == 0 && !wakenUp.get()) {
  4. long timeBlocked = System.currentTimeMillis() - beforeSelect;
  5.  
  6. if (timeBlocked < minSelectTimeout) {
  7. boolean notConnected = false;
  8. for (SelectionKey key: selector.keys()) {
  9. AbstractNioChannel<?> ch = (AbstractNioChannel<?>) key.attachment();
  10. if (!ch.isConnected()) {
  11. notConnected = true;
  12. break;
  13. }
  14. }
  15. if (notConnected) {
  16. selectReturnsImmediately = 0;
  17. } else {
  18. // returned before the minSelectTimeout elapsed with nothing select.
  19. // this may be the cause of the jdk epoll(..) bug, so increment the counter
  20. // which we use later to see if its really the jdk bug.
  21. selectReturnsImmediately ++;
  22.  
  23. System.out.println("blocked=" + timeBlocked + " min=" + minSelectTimeout
  24. + "times=" + selectReturnsImmediately);
  25. }
  26.  
  27. } else {
  28. selectReturnsImmediately = 0;
  29. }
Add Comment
Please, Sign In to add comment