Skip to content

Commit

Permalink
(feat) Avoid deadlock when disruptor queue is full.
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Nov 4, 2019
1 parent bc4c4b8 commit b1cc39a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ public synchronized void shutdown() {

if (this.taskQueue != null) {
final CountDownLatch latch = new CountDownLatch(1);
enqueueTask((task, sequence) -> {
task.reset();
task.type = TaskType.SHUTDOWN;
task.shutdownLatch = latch;
});
this.shutdownLatch = latch;
Utils.runInThread(() -> {
this.taskQueue.publishEvent((task, sequence) -> {
task.reset();
task.type = TaskType.SHUTDOWN;
task.shutdownLatch = latch;
});
});
}
doShutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,11 @@ public boolean init(final LogManagerOptions opts) {

private void stopDiskThread() {
this.shutDownLatch = new CountDownLatch(1);
this.diskQueue.publishEvent((event, sequence) -> {
event.reset();
event.type = EventType.SHUTDOWN;
Utils.runInThread(() -> {
this.diskQueue.publishEvent((event, sequence) -> {
event.reset();
event.type = EventType.SHUTDOWN;
});
});
}

Expand Down

0 comments on commit b1cc39a

Please sign in to comment.