Skip to content

Commit

Permalink
LocalLog: Cancel signal when unused
Browse files Browse the repository at this point in the history
Patch by Alex Petrov; reviewed by Marcus Eriksson and Sam Tunnicliffe for CASSANDRA-19353.
  • Loading branch information
ifesdjeen committed Mar 19, 2024
1 parent 98ca5f8 commit 2924762
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/java/org/apache/cassandra/tcm/log/LocalLog.java
Expand Up @@ -750,20 +750,24 @@ private AsyncRunnable()

public void run(Interruptible.State state) throws InterruptedException
{
WaitQueue.Signal signal = null;
try
{
if (state != Interruptible.State.SHUTTING_DOWN)
{
Condition condition = subscriber.getAndSet(null);
// Grab a ticket ahead of time, so that we can't get into race with the exit from process pending
WaitQueue.Signal signal = logNotifier.register();
signal = logNotifier.register();
processPendingInternal();
if (condition != null)
condition.signalAll();
// if no new threads have subscribed since we started running, await
// otherwise, run again to process whatever work they may be waiting on
if (subscriber.get() == null)
{
signal.await();
signal = null;
}
}
}
catch (StopProcessingException t)
Expand All @@ -780,6 +784,12 @@ public void run(Interruptible.State state) throws InterruptedException
// TODO handle properly
logger.warn("Error in log follower", t);
}
finally
{
// If signal was not consumed for some reason, cancel it
if (signal != null)
signal.cancel();
}
}
}

Expand Down

0 comments on commit 2924762

Please sign in to comment.