Skip to content

Commit

Permalink
Fix ConsumeDriver running status (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCqupt authored Jan 19, 2025
1 parent 3549537 commit affbaa8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Release Notes.
* Add Caffeine plugin as optional.
* Add Undertow 2.1.7.final+ worker thread pool metrics.
* Support for tracking in spring gateway versions 4.1.2 and above.
* Fix `ConsumeDriver` running status concurrency issues.

All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Pool of consumers <p> Created by wusheng on 2016/10/25.
*/
public class ConsumeDriver<T> implements IDriver {
private boolean running;
private volatile boolean running;
private ConsumerThread[] consumerThreads;
private Channels<T> channels;
private ReentrantLock lock;
Expand Down Expand Up @@ -88,6 +88,9 @@ public void begin(Channels channels) {
}
lock.lock();
try {
if (running) {
return;
}
this.allocateBuffer2Thread();
for (ConsumerThread consumerThread : consumerThreads) {
consumerThread.start();
Expand Down Expand Up @@ -124,8 +127,14 @@ private void allocateBuffer2Thread() {

@Override
public void close(Channels channels) {
if (!running) {
return;
}
lock.lock();
try {
if (!running) {
return;
}
this.running = false;
for (ConsumerThread consumerThread : consumerThreads) {
consumerThread.shutdown();
Expand Down

0 comments on commit affbaa8

Please sign in to comment.