Skip to content

Commit 736e80e

Browse files
committed
Revert outThread of 282a683 to 9b94a33...
...which did not resolve hanging on 48-core DragonFly BSD test.
1 parent ce586fb commit 736e80e

File tree

12 files changed

+23
-239
lines changed

12 files changed

+23
-239
lines changed

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

Lines changed: 6 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
import java.io.StringReader;
3333
import java.util.ArrayList;
3434
import java.util.List;
35-
import java.util.concurrent.ScheduledFuture;
36-
import java.util.concurrent.ScheduledThreadPoolExecutor;
37-
import java.util.concurrent.TimeUnit;
3835
import java.util.logging.Level;
3936
import java.util.logging.Logger;
4037
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
@@ -49,25 +46,10 @@
4946
public class Ctags {
5047

5148
private static final Logger LOGGER = LoggerFactory.getLogger(Ctags.class);
52-
private static final long SIGNALWAIT_MS = 5000;
5349

54-
/**
55-
* Wait up to 90 seconds for ctags to run, which is a very long time for a
56-
* single run but is really intended for detecting blocked ctags processes
57-
* as happened with @tuxillo's testing of
58-
* <a href="https://github.com/oracle/opengrok/pull/1936">
59-
* Feature/deferred_ops</a>.
60-
*/
61-
private static final long CTAGSWAIT_S = 90;
62-
63-
private final ScheduledThreadPoolExecutor schedExecutor;
64-
private final CtagsBuffer buffer = new CtagsBuffer();
65-
private final Object syncRoot = new Object();
6650
private volatile boolean closing;
67-
private volatile boolean signalled;
6851
private Process ctags;
6952
private Thread errThread;
70-
private Thread outThread;
7153
private OutputStreamWriter ctagsIn;
7254
private BufferedReader ctagsOut;
7355
private static final String CTAGS_FILTER_TERMINATOR = "__ctags_done_with_file__";
@@ -78,27 +60,13 @@ public class Ctags {
7860
private boolean junit_testing = false;
7961

8062
/**
81-
* Initializes an instance using the specified, required executor which
82-
* will be used to track ctags timeouts to avoid blockages.
83-
* <p>(The {@code schedExecutor} is not owned by {@link Ctags}.)
84-
* @param schedExecutor required, defined instance
85-
*/
86-
public Ctags(ScheduledThreadPoolExecutor schedExecutor) {
87-
if (schedExecutor == null) {
88-
throw new IllegalArgumentException("`schedExecutor' is null");
89-
}
90-
this.schedExecutor = schedExecutor;
91-
}
92-
93-
/**
94-
* Gets a value indicating if a subprocess of ctags was started and either:
95-
* 1) it is not alive; or 2) any necessary supporting thread is not alive.
63+
* Gets a value indicating if a subprocess of ctags was started and it is
64+
* not alive.
9665
* @return {@code true} if the instance should be considered closed and no
9766
* longer usable.
9867
*/
9968
public boolean isClosed() {
100-
return ctags != null && (!ctags.isAlive() || outThread == null ||
101-
!outThread.isAlive());
69+
return ctags != null && !ctags.isAlive();
10270
}
10371

10472
public String getBinary() {
@@ -354,12 +322,6 @@ public void run() {
354322
});
355323
errThread.setDaemon(true);
356324
errThread.start();
357-
358-
if (outThread == null || !outThread.isAlive()) {
359-
outThread = new Thread(() -> outThreadStart());
360-
outThread.setDaemon(true);
361-
outThread.start();
362-
}
363325
}
364326

365327
public Definitions doCtags(String file) throws IOException,
@@ -382,44 +344,24 @@ public Definitions doCtags(String file) throws IOException,
382344
initialize();
383345
}
384346

385-
synchronized(syncRoot) {
386-
signalled = true;
387-
syncRoot.notify();
388-
}
389-
390-
Thread clientThread = Thread.currentThread();
391-
ScheduledFuture futureTimeout = schedExecutor.schedule(() -> {
392-
LOGGER.log(Level.FINE, "Ctags futureTimeout executing re t{0}.",
393-
clientThread.getId());
394-
clientThread.interrupt();
395-
outThread.interrupt();
396-
ctags.destroyForcibly();
397-
LOGGER.log(Level.FINE, "Ctags futureTimeout executed.");
398-
}, CTAGSWAIT_S, TimeUnit.SECONDS);
399-
347+
CtagsReader rdr = new CtagsReader();
400348
Definitions ret;
401349
try {
402350
ctagsIn.write(file);
403351
if (Thread.interrupted()) throw new InterruptedException("write()");
404352
ctagsIn.flush();
405353
if (Thread.interrupted()) throw new InterruptedException("flush()");
406-
ret = buffer.take();
354+
readTags(rdr);
355+
ret = rdr.getDefinitions();
407356
} catch (IOException ex) {
408357
/*
409358
* In case the ctags process had to be destroyed, possibly pre-empt
410359
* the IOException with an InterruptedException.
411360
*/
412361
if (Thread.interrupted()) throw new InterruptedException("I/O");
413362
throw ex;
414-
} finally {
415-
futureTimeout.cancel(false);
416363
}
417364

418-
/*
419-
* If the timeout could not be canceled in time, then act as if no
420-
* results were obtained.
421-
*/
422-
if (Thread.interrupted()) throw new InterruptedException("late");
423365
return ret;
424366
}
425367

@@ -518,45 +460,4 @@ private void readTags(CtagsReader reader) throws InterruptedException {
518460
}
519461
LOGGER.severe("CTag reader cycle was interrupted!");
520462
}
521-
522-
private void outThreadStart() {
523-
while (!closing) {
524-
synchronized(syncRoot) {
525-
while (!signalled && !closing) {
526-
try {
527-
syncRoot.wait(SIGNALWAIT_MS);
528-
} catch (InterruptedException e) {
529-
LOGGER.log(Level.WARNING,
530-
"Ctags outThread unexpectedly interrupted--{0}",
531-
e.getMessage());
532-
/*
533-
* Terminating this thread will cause this Ctags
534-
* instance, which appears to be blocked, to be
535-
* reported as closed by isClosed().
536-
*/
537-
return;
538-
}
539-
}
540-
signalled = false;
541-
}
542-
if (closing) return;
543-
544-
CtagsReader rdr = new CtagsReader();
545-
try {
546-
readTags(rdr);
547-
Definitions defs = rdr.getDefinitions();
548-
buffer.put(defs);
549-
} catch (InterruptedException ex) {
550-
LOGGER.log(Level.WARNING,
551-
"Ctags outThread unexpectedly interrupted--{0}",
552-
ex.getMessage());
553-
/*
554-
* Terminating this thread will cause this Ctags instance,
555-
* which appears to be blocked, to be reported as closed by
556-
* isClosed().
557-
*/
558-
return;
559-
}
560-
}
561-
}
562463
}

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

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/org/opensolaris/opengrok/index/IndexerParallelizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public void close() throws Exception {
110110
* @return a defined instance, possibly with a {@code null} ctags binary
111111
* setting if a value was not available from {@link RuntimeEnvironment}.
112112
*/
113-
private Ctags getNewCtags(RuntimeEnvironment env) {
114-
Ctags ctags = new Ctags(schedExecutor);
113+
private static Ctags getNewCtags(RuntimeEnvironment env) {
114+
Ctags ctags = new Ctags();
115115

116116
String ctagsBinary = env.getCtags();
117117
if (ctagsBinary == null) {

test/org/opensolaris/opengrok/analysis/CtagsParserTest.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,15 @@
2323
*/
2424
package org.opensolaris.opengrok.analysis;
2525

26-
import java.util.concurrent.ScheduledThreadPoolExecutor;
27-
import org.junit.AfterClass;
2826
import static org.junit.Assert.assertEquals;
2927
import org.junit.Test;
30-
import org.junit.BeforeClass;
3128

3229
/**
3330
*
3431
* @author Lubos Kosco
3532
*/
3633
public class CtagsParserTest {
3734

38-
private static ScheduledThreadPoolExecutor schedExecutor;
39-
40-
@BeforeClass
41-
public static void setUpClass() throws Exception {
42-
schedExecutor = new ScheduledThreadPoolExecutor(2);
43-
}
44-
45-
@AfterClass
46-
public static void tearDownClass() throws Exception {
47-
if (schedExecutor != null) schedExecutor.shutdown();
48-
}
49-
5035
@Test
5136
public void ctags_vs_universal_ctags() throws Exception {
5237
String universal_ctags_c = "TEST\tsample.c\t/^#define TEST($/;\"\tmacro\tline:6\tsignature:(x)\n"
@@ -67,7 +52,7 @@ public void ctags_vs_universal_ctags() throws Exception {
6752
+ "f\tsample.c\t/^ int f;$/;\"\tlocal\tline:28\n"
6853
+ "main\tsample.c\t/^int main(int argc, char *argv[]) {$/;\"\tfunction\tline:41\tsignature:(int argc, char *argv[])\n"
6954
+ "res\tsample.c\t/^ int res;$/;\"\tlocal\tline:42";
70-
Ctags lctags = new Ctags(schedExecutor);
55+
Ctags lctags = new Ctags();
7156
Definitions ucDefs = lctags.testCtagsParser(universal_ctags_c);
7257

7358
Definitions cDefs = lctags.testCtagsParser(ctags_c);

test/org/opensolaris/opengrok/analysis/CtagsTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import java.io.File;
2828
import java.io.IOException;
29-
import java.util.concurrent.ScheduledThreadPoolExecutor;
3029
import org.junit.After;
3130
import org.junit.AfterClass;
3231
import static org.junit.Assert.assertEquals;
@@ -42,7 +41,6 @@
4241
* @author Lubos Kosco
4342
*/
4443
public class CtagsTest {
45-
private static ScheduledThreadPoolExecutor schedExecutor;
4644
private static Ctags ctags;
4745
private static TestRepository repository;
4846

@@ -51,8 +49,7 @@ public CtagsTest() {
5149

5250
@BeforeClass
5351
public static void setUpClass() throws Exception {
54-
schedExecutor = new ScheduledThreadPoolExecutor(2);
55-
ctags = new Ctags(schedExecutor);
52+
ctags = new Ctags();
5653
ctags.setBinary(RuntimeEnvironment.getInstance().getCtags());
5754

5855
repository = new TestRepository();
@@ -79,7 +76,6 @@ public static void tearDownClass() throws Exception {
7976
ctags = null;
8077
repository.destroy();
8178
repository = null;
82-
if (schedExecutor != null) schedExecutor.shutdown();
8379
}
8480

8581
@Before

test/org/opensolaris/opengrok/analysis/JFlexXrefTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.io.StringReader;
3434
import java.io.StringWriter;
3535
import java.util.Arrays;
36-
import java.util.concurrent.ScheduledThreadPoolExecutor;
3736
import javax.xml.parsers.DocumentBuilderFactory;
3837
import org.apache.lucene.document.Document;
3938
import org.junit.AfterClass;
@@ -68,7 +67,6 @@
6867
*/
6968
public class JFlexXrefTest {
7069

71-
private static ScheduledThreadPoolExecutor schedExecutor;
7270
private static Ctags ctags;
7371
private static TestRepository repository;
7472

@@ -81,8 +79,7 @@ public class JFlexXrefTest {
8179

8280
@BeforeClass
8381
public static void setUpClass() throws Exception {
84-
schedExecutor = new ScheduledThreadPoolExecutor(2);
85-
ctags = new Ctags(schedExecutor);
82+
ctags = new Ctags();
8683
ctags.setBinary(RuntimeEnvironment.getInstance().getCtags());
8784
repository = new TestRepository();
8885
repository.create(JFlexXrefTest.class.getResourceAsStream(
@@ -94,7 +91,6 @@ public static void tearDownClass() throws Exception {
9491
ctags.close();
9592
ctags = null;
9693
repository.destroy();
97-
if (schedExecutor != null) schedExecutor.shutdown();
9894
}
9995

10096
/**

0 commit comments

Comments
 (0)