Skip to content

Commit

Permalink
Merge pull request #123 from jenkinsci/disable-nio
Browse files Browse the repository at this point in the history
[FIXED JENKINS-39290] A debug flag to disable NIO
  • Loading branch information
kohsuke committed Oct 27, 2016
2 parents 9dc9317 + 678d9e9 commit 6575e82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/configuration.md
Expand Up @@ -92,6 +92,14 @@ These properties require independent configuration on both sides of the channel.
Property example: <code>org.jenkinsci.remoting.engine.JnlpProtocol3.disabled</code>
</td>
</tr>
<tr>
<td>org.jenkinsci.remoting.nio.NioChannelHub.disabled</td>
<td>false</td>
<td>2.62.3</td>
<td>?</td>
<td><a href="https://issues.jenkins-ci.org/browse/JENKINS-39290">JENKINS-39290</a></td>
<td>Boolean flag to disable NIO-based socket connection handling, and switch back to classic IO. Used to isolate the problem.</td>
</tr>-
<!--Template
<tr>
<td></td>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -177,6 +177,7 @@ THE SOFTWARE.
<artifactId>access-modifier-annotation</artifactId>
<version>1.7</version>
<type>jar</type>
<optional>true</optional><!-- no need to have this at runtime -->
</dependency>
</dependencies>

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/jenkinsci/remoting/nio/NioChannelHub.java
Expand Up @@ -11,6 +11,8 @@
import hudson.remoting.CommandTransport;
import hudson.remoting.SingleLaneExecutorService;
import org.jenkinsci.remoting.RoleChecker;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import java.io.Closeable;
import java.io.EOFException;
Expand Down Expand Up @@ -472,7 +474,8 @@ public NioChannelBuilder newChannelBuilder(String name, ExecutorService es) {
protected CommandTransport makeTransport(InputStream is, OutputStream os, Mode mode, Capability cap) throws IOException {
if (r==null) r = factory.create(is);
if (w==null) w = factory.create(os);
if (r!=null && w!=null && mode==Mode.BINARY && cap.supportsChunking()) {
boolean disableNio = Boolean.getBoolean(NioChannelHub.class.getName()+".disabled");
if (r!=null && w!=null && mode==Mode.BINARY && cap.supportsChunking() && !disableNio) {
try {
// run() might be called asynchronously from another thread, so wait until that gets going
// if you see the execution hanging here forever, that means you forgot to call run()
Expand All @@ -492,9 +495,9 @@ protected CommandTransport makeTransport(InputStream is, OutputStream os, Mode m
else t = new DualNioTransport(getName(),r,w,cap);
t.scheduleReregister();
return t;
}
else
} else {
return super.makeTransport(is, os, mode, cap);
}
}
};
}
Expand Down

0 comments on commit 6575e82

Please sign in to comment.