Merge pull request #3011 from chengzhichao-xydt/codex/legacy-events-ok-assert
fix(agent): add ok check for LoadAndDelete type assertion
This commit is contained in:
commit
71524183b6
1 changed files with 10 additions and 1 deletions
|
|
@ -2,11 +2,13 @@ package agent
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/sipeed/picoclaw/pkg/bus"
|
||||
runtimeevents "github.com/sipeed/picoclaw/pkg/events"
|
||||
"github.com/sipeed/picoclaw/pkg/logger"
|
||||
)
|
||||
|
||||
const defaultEventSubscriberBuffer = 16
|
||||
|
|
@ -88,7 +90,14 @@ func (al *AgentLoop) UnsubscribeEvents(id uint64) {
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
sub := value.(legacyEventSubscription)
|
||||
sub, ok := value.(legacyEventSubscription)
|
||||
if !ok {
|
||||
logger.WarnCF("agent", "UnsubscribeEvents: unexpected type in subscription map", map[string]any{
|
||||
"id": id,
|
||||
"type": fmt.Sprintf("%T", value),
|
||||
})
|
||||
return
|
||||
}
|
||||
sub.cancel()
|
||||
if sub.sub != nil {
|
||||
_ = sub.sub.Close()
|
||||
|
|
|
|||
Loading…
Reference in a new issue