提交 1b2035e2 编写于 作者: K kohsuke

fixed #349.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2368 71c3de6d-444a-0410-be80-ed276b4c234a
上级 b237dbdb
......@@ -11,6 +11,7 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
......@@ -135,7 +136,7 @@ public class TcpSlaveAgentListener extends Thread {
}
String nodeName = in.readUTF();
Computer computer = Hudson.getInstance().getComputer(nodeName);
ComputerImpl computer = (ComputerImpl) Hudson.getInstance().getComputer(nodeName);
if(computer==null) {
error(out, "No such slave: "+nodeName);
return;
......@@ -148,7 +149,10 @@ public class TcpSlaveAgentListener extends Thread {
out.println("Welcome");
((ComputerImpl)computer).setChannel(s.getInputStream(),s.getOutputStream(),null,
OutputStream log = computer.openLogFile();
new PrintWriter(log).println("JNLP agent connected from "+s.getInetAddress());
computer.setChannel(s.getInputStream(),s.getOutputStream(),log,
new Listener() {
public void onClosed(Channel channel, IOException cause) {
if(cause!=null)
......
......@@ -229,14 +229,7 @@ public final class Slave implements Node, Serializable {
private void launch(final Slave slave) {
closeChannel();
OutputStream os;
try {
os = new FileOutputStream(getLogFile());
} catch (FileNotFoundException e) {
logger.log(Level.SEVERE, "Failed to create log file "+getLogFile(),e);
os = new NullStream();
}
final OutputStream launchLog = os;
final OutputStream launchLog = openLogFile();
if(slave.agentCommand.length()>0) {
// launch the slave agent asynchronously
......@@ -282,6 +275,17 @@ public final class Slave implements Node, Serializable {
}
}
public OutputStream openLogFile() {
OutputStream os;
try {
os = new FileOutputStream(getLogFile());
} catch (FileNotFoundException e) {
logger.log(Level.SEVERE, "Failed to create log file "+getLogFile(),e);
os = new NullStream();
}
return os;
}
private final Object channelLock = new Object();
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册