Skip to content

Disconnect Stats panic #215

Open
Open
@PFangwang

Description

@PFangwang

your func:

func (c *StatsConnection) Disconnect() {
	if c == nil {
		return
	}
	if c.statsClient != nil {
		if err := c.statsClient.Disconnect(); err != nil {
			log.Debugf("disconnecting stats client failed: %v", err)
		}
	}
	close(c.connChan)
	close(c.done)
}

in another fiber:

case <-c.done:
	log.Debugf("health check watcher closed")
	c.sendStatsConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Disconnected, Error: nil})
	return
}

func sendStatsConnEvent:

func (c *StatsConnection) sendStatsConnEvent(event ConnectionEvent) {
	select {
	case c.connChan <- event:
	default:
		log.Warn("Stats connection state channel is full, discarding value.")
	}
}

note this: case c.connChan <- event:
now the c.connChan is cloed,then panic

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions