Skip to content

Commit d7c777f

Browse files
修复datacollection连接未关闭的问题
1 parent fe2bdc0 commit d7c777f

File tree

1 file changed

+5
-2
lines changed
  • src/scene_server/datacollection/datacollection

1 file changed

+5
-2
lines changed

src/scene_server/datacollection/datacollection/porter.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func BuildChanPorter(name string, analyzer Analyzer, redisCli, snapCli *redis.Cl
5050
slaveC: make(chan string, cacheSize),
5151
analyzeCounterC: make(chan int, runtime.NumCPU()),
5252
runed: util.NewBool(false),
53-
Engine: engine,
53+
Engine: engine,
5454
}
5555

5656
ns := "cmdb_collector_" + name + "_"
@@ -269,7 +269,10 @@ func (p *chanPorter) subscribeLoop() error {
269269
if nil != err {
270270
return fmt.Errorf("subscribe channel failed, %v", err)
271271
}
272-
defer subChan.Unsubscribe(p.channels...)
272+
defer func() {
273+
_ = subChan.Unsubscribe(p.channels...)
274+
_ = subChan.Close()
275+
}()
273276

274277
blog.Info("[data-collection][%s] subscribing channel %v from redis", p.name, p.channels)
275278
defer blog.Info("[data-collection][%s] unsubscribe channel %v from redis", p.name, p.channels)

0 commit comments

Comments
 (0)