Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-27555]: Fix selector loop exit condition
  • Loading branch information
ydubreuil committed Jun 2, 2015
1 parent 37c4469 commit 166ca5a
Showing 1 changed file with 17 additions and 13 deletions.
Expand Up @@ -90,20 +90,24 @@ public String start() throws Exception {
final class AgentSocketAcceptor implements Runnable {
public void run() {
try {
// The select() will be woke up if some new connection
// have occurred, or if the selector has been explicitly
// woke up
while (selector.select() > 0 && selectable) {
Iterator<SelectionKey> selectedKeys = selector.selectedKeys().iterator();

while(selectedKeys.hasNext()) {
SelectionKey key = selectedKeys.next();
selectedKeys.remove();

if (key.isValid()) {
EventHandler processor = ((EventHandler) key.attachment());
processor.process(key);
while (selectable) {
// The select() will be woke up if some new connection
// have occurred, or if the selector has been explicitly
// woke up
if (selector.select() > 0) {
Iterator<SelectionKey> selectedKeys = selector.selectedKeys().iterator();

while(selectedKeys.hasNext()) {
SelectionKey key = selectedKeys.next();
selectedKeys.remove();

if (key.isValid()) {
EventHandler processor = ((EventHandler) key.attachment());
processor.process(key);
}
}
} else {

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 4, 2015

Member

@ydubreuil I think this causes another bug. We should loop as long as selectable. breaking after the first wake is not the right thing to do here at all

break;
}
}

Expand Down

0 comments on commit 166ca5a

Please sign in to comment.