Skip to content

Commit ce586fb

Browse files
committed
Revert startThread of bb0160c, which did not resolve hanging...
... on 48-processor server.
1 parent bb0160c commit ce586fb

File tree

1 file changed

+4
-60
lines changed

1 file changed

+4
-60
lines changed

src/org/opensolaris/opengrok/analysis/Ctags.java

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public class Ctags {
6565
private final Object syncRoot = new Object();
6666
private volatile boolean closing;
6767
private volatile boolean signalled;
68-
private volatile Process ctags;
69-
private volatile IOException startIOException;
68+
private Process ctags;
7069
private Thread errThread;
7170
private Thread outThread;
7271
private OutputStreamWriter ctagsIn;
@@ -75,7 +74,6 @@ public class Ctags {
7574
//default: setCtags(System.getProperty("org.opensolaris.opengrok.analysis.Ctags", "ctags"));
7675
private String binary;
7776
private String CTagsExtraOptionsFile = null;
78-
private ProcessBuilder processBuilder;
7977

8078
private boolean junit_testing = false;
8179

@@ -124,8 +122,9 @@ public void close() throws IOException {
124122
}
125123
}
126124

127-
private void initialize() throws IOException, InterruptedException {
125+
private void initialize() throws IOException {
128126
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
127+
ProcessBuilder processBuilder;
129128
if (true) {
130129
List<String> command = new ArrayList<>();
131130

@@ -330,62 +329,7 @@ private void initialize() throws IOException, InterruptedException {
330329
processBuilder = new ProcessBuilder(command);
331330
}
332331

333-
Thread clientThread = Thread.currentThread();
334-
335-
startIOException = null;
336-
// Start ctags on a separate, daemon thread in case start() blocks.
337-
Thread startThread = new Thread(() -> {
338-
try {
339-
Process newCtags = processBuilder.start();
340-
LOGGER.log(Level.FINE, "Executed ctags command re t{0}",
341-
clientThread.getId());
342-
synchronized(syncRoot) {
343-
ctags = newCtags;
344-
syncRoot.notify();
345-
}
346-
} catch (IOException e) {
347-
startIOException = e;
348-
}
349-
});
350-
startThread.setDaemon(true);
351-
startThread.start();
352-
353-
// Set a timeout so the client thread does not wait indefinitely.
354-
ScheduledFuture startTimeout = schedExecutor.schedule(() -> {
355-
LOGGER.log(Level.FINE, "Ctags startTimeout executing re t{0}.",
356-
clientThread.getId());
357-
clientThread.interrupt();
358-
/**
359-
* No point in interrupting startThread, since nothing it executes
360-
* is interruptible.
361-
*/
362-
LOGGER.log(Level.FINE, "Ctags startTimeout executed.");
363-
}, CTAGSWAIT_S, TimeUnit.SECONDS);
364-
365-
// Wait until startThread sets the ctags field, until timeout, or error.
366-
synchronized(syncRoot) {
367-
while (ctags == null) {
368-
if (startIOException != null) {
369-
startTimeout.cancel(false);
370-
throw startIOException;
371-
}
372-
try {
373-
syncRoot.wait(SIGNALWAIT_MS);
374-
} catch (InterruptedException e) {
375-
LOGGER.log(Level.WARNING, "Ctags did not start--{0}",
376-
e.getMessage());
377-
startTimeout.cancel(false);
378-
throw e;
379-
}
380-
}
381-
}
382-
383-
startTimeout.cancel(false);
384-
/*
385-
* If the timeout could not be truly canceled in time, then ignore it.
386-
*/
387-
Thread.interrupted();
388-
332+
ctags = processBuilder.start();
389333
ctagsIn = new OutputStreamWriter(ctags.getOutputStream());
390334
ctagsOut = new BufferedReader(new InputStreamReader(ctags.getInputStream()));
391335

0 commit comments

Comments
 (0)