提交 2579ceaf 编写于 作者: K Kohsuke Kawaguchi

NioChannelHub must be explicitly shut down

... or else it'll keep running. This can be seen as a large number of zombie threads like the following in the unit test:

"NioChannelHub keys=0 gen=0: Computer.threadPoolForRemoting [#250]" daemon prio=10 tid=0x00007f793d841000 nid=0x3cc1 runnable [0x00007f78e2665000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:228)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:81)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
        - locked <0x00000000c50d46d8> (a sun.nio.ch.Util$2)
        - locked <0x00000000c50d46e8> (a java.util.Collections$UnmodifiableSet)
        - locked <0x00000000c50d4690> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:102)
        at org.jenkinsci.remoting.nio.NioChannelHub.run(NioChannelHub.java:542)
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
上级 0ebf47bd
package jenkins.slaves;
import hudson.Extension;
import hudson.init.Terminator;
import hudson.model.Computer;
import org.jenkinsci.remoting.nio.NioChannelHub;
......@@ -34,6 +35,14 @@ public class NioChannelSelector {
return hub;
}
@Terminator
public void cleanUp() throws IOException {
if (hub!=null) {
hub.close();
hub = null;
}
}
/**
* Escape hatch to disable use of NIO.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册