Skip to content

Commit 9429b82

Browse files
authored
feat(event): optimize event service thread close logic (#6463)
1 parent e19b2a1 commit 9429b82

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

framework/src/main/java/org/tron/core/services/event/HistoryEventService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class HistoryEventService {
2929
@Autowired
3030
private Manager manager;
3131

32+
private volatile boolean isClosed = false;
33+
3234
private volatile Thread thread;
3335

3436
public void init() {
@@ -44,6 +46,7 @@ public void init() {
4446
}
4547

4648
public void close() {
49+
isClosed = true;
4750
if (thread != null) {
4851
try {
4952
thread.interrupt();
@@ -61,7 +64,7 @@ private void syncEvent() {
6164
long tmp = instance.getStartSyncBlockNum();
6265
long endNum = manager.getDynamicPropertiesStore().getLatestSolidifiedBlockNum();
6366
while (tmp < endNum) {
64-
if (thread.isInterrupted()) {
67+
if (thread.isInterrupted() || isClosed) {
6568
throw new InterruptedException();
6669
}
6770
if (instance.isUseNativeQueue()) {

0 commit comments

Comments
 (0)