Skip to content
Permalink
Browse files

[JENKINS-27555]: Fix selector loop exit condition

  • Loading branch information...
ydubreuil committed Jun 2, 2015
1 parent 37c4469 commit 166ca5a34d0a16b2d826dff0215225edbd3f623f
Showing with 17 additions and 13 deletions.
  1. +17 −13 src/main/java/com/cloudbees/jenkins/plugins/sshagent/jna/AgentServer.java
@@ -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;
}
}

0 comments on commit 166ca5a

Please sign in to comment.
You can’t perform that action at this time.