Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnect Stats panic #215

Open
PFangwang opened this issue May 23, 2024 · 0 comments
Open

Disconnect Stats panic #215

PFangwang opened this issue May 23, 2024 · 0 comments
Assignees
Labels

Comments

@PFangwang
Copy link

PFangwang commented May 23, 2024

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

@ondrej-fabry ondrej-fabry self-assigned this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants