Skip to content

Commit

Permalink
fix: 修复日志循环打印问题
Browse files Browse the repository at this point in the history
  • Loading branch information
feng626 committed Sep 4, 2023
1 parent 02ef71b commit 9e6144d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/jms/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ func (p *PollJMSEvent) clearZombieSession() {
resp, err := grpc.GlobalGrpcClient.Client.ScanRemainReplays(ctx, req)
if err != nil || !resp.Status.Ok {
logger.GlobalLogger.Error("Failed to scan remain replay")
} else {
logger.GlobalLogger.Info("Scan remain replay success")
}
}

Expand All @@ -40,17 +38,19 @@ func (p *PollJMSEvent) waitForKillSessionMessage() {
logger.GlobalLogger.Error("dispatch task err", zap.Error(err))
return
}
waitChan := make(chan struct{})
closeStreamChan := make(chan struct{})
for {
taskResponse, err := stream.Recv()
if err == io.EOF {
_ = stream.CloseSend()
close(waitChan)
close(closeStreamChan)
break
}
if err != nil {
logger.GlobalLogger.Error("Failed to receive a note", zap.Error(err))
continue
_ = stream.CloseSend()
close(closeStreamChan)
break
}

task := taskResponse.Task
Expand All @@ -75,7 +75,8 @@ func (p *PollJMSEvent) waitForKillSessionMessage() {
}
}
}
<-waitChan
<-closeStreamChan
p.waitForKillSessionMessage()
}
func (p *PollJMSEvent) sendFinishTask(stream protobuf.Service_DispatchTaskClient, TaskId string) {
req := &protobuf.FinishedTaskRequest{
Expand Down

0 comments on commit 9e6144d

Please sign in to comment.