fix: prevent dangling XMPP connections during configuration updates
- Add getConfiguration() methods to both bridges for thread-safe config access - Refactor UpdateConfiguration() methods to prevent mutex deadlock by releasing lock before blocking operations - Fix XMPP bridge to properly disconnect existing bridgeClient before creating new one - Add comprehensive timeout support to XMPP client (30s connection, 10s operations, 5s ping) - Implement proper disconnection with offline presence - Update all interfaces to use *config.Configuration for type safety 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
65038fb7a2
commit
69a67704f4
6 changed files with 121 additions and 55 deletions
|
@ -52,11 +52,18 @@ func NewBridge(log logger.Logger, api plugin.API, kvstore kvstore.KVStore, cfg *
|
|||
return bridge
|
||||
}
|
||||
|
||||
// getConfiguration safely retrieves the current configuration
|
||||
func (b *mattermostBridge) getConfiguration() *config.Configuration {
|
||||
b.configMu.RLock()
|
||||
defer b.configMu.RUnlock()
|
||||
return b.config
|
||||
}
|
||||
|
||||
// UpdateConfiguration updates the bridge configuration
|
||||
func (b *mattermostBridge) UpdateConfiguration(newConfig any) error {
|
||||
cfg, ok := newConfig.(*config.Configuration)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid configuration type")
|
||||
func (b *mattermostBridge) UpdateConfiguration(cfg *config.Configuration) error {
|
||||
// Validate configuration using built-in validation
|
||||
if err := cfg.IsValid(); err != nil {
|
||||
return fmt.Errorf("invalid configuration: %w", err)
|
||||
}
|
||||
|
||||
b.configMu.Lock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue