Skip to content

Commit 4c120df

Browse files
committed
Use destroyForcibly() for a non-responsive ctags process
1 parent 9b94a33 commit 4c120df

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.analysis;
2525

@@ -392,9 +392,10 @@ public Definitions doCtags(String file) throws IOException,
392392

393393
Thread clientThread = Thread.currentThread();
394394
ScheduledFuture futureTimeout = schedExecutor.schedule(() -> {
395+
LOGGER.log(Level.WARNING, "Ctags futureTimeout executing.");
395396
clientThread.interrupt();
396397
outThread.interrupt();
397-
LOGGER.log(Level.WARNING, "Ctags futureTimeout executed.");
398+
ctags.destroyForcibly();
398399
}, CTAGSWAIT_S, TimeUnit.SECONDS);
399400

400401
Definitions ret;
@@ -404,6 +405,13 @@ public Definitions doCtags(String file) throws IOException,
404405
ctagsIn.flush();
405406
if (Thread.interrupted()) throw new InterruptedException("flush()");
406407
ret = buffer.take();
408+
} catch (IOException ex) {
409+
/*
410+
* In case the ctags process had to be destroyed, possibly pre-empt
411+
* the IOException with an InterruptedException.
412+
*/
413+
if (Thread.interrupted()) throw new InterruptedException("I/O");
414+
throw ex;
407415
} finally {
408416
futureTimeout.cancel(false);
409417
}
@@ -537,6 +545,9 @@ private void outThreadStart() {
537545
CtagsReader rdr = new CtagsReader();
538546
try {
539547
readTags(rdr);
548+
if (Thread.interrupted()) {
549+
throw new InterruptedException("readTags()");
550+
}
540551
Definitions defs = rdr.getDefinitions();
541552
buffer.put(defs);
542553
} catch (InterruptedException ex) {

0 commit comments

Comments
 (0)