Better practices
This commit is contained in:
parent
536f3cd6b8
commit
8e67699fe4
3 changed files with 6 additions and 5 deletions
|
@ -136,7 +136,7 @@ func CloseAllAccountsForShutdown() {
|
||||||
|
|
||||||
for _, accl := range registeredAccounts {
|
for _, accl := range registeredAccounts {
|
||||||
for _, acct := range accl {
|
for _, acct := range accl {
|
||||||
log.Printf("Closing %#v", acct)
|
log.Printf("Closing %s %s (%s)", acct.MatrixUser, acct.AccountName, acct.Protocol)
|
||||||
acct.Conn.Close()
|
acct.Conn.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
connector/external/external.go
vendored
1
connector/external/external.go
vendored
|
@ -338,6 +338,7 @@ func (ext *External) Close() {
|
||||||
ext.proc.Process.Kill()
|
ext.proc.Process.Kill()
|
||||||
}()
|
}()
|
||||||
ext.proc.Wait()
|
ext.proc.Wait()
|
||||||
|
log.Info("External process exited")
|
||||||
|
|
||||||
ext.proc = nil
|
ext.proc = nil
|
||||||
ext.recvPipe = nil
|
ext.recvPipe = nil
|
||||||
|
|
|
@ -31,7 +31,7 @@ type Mattermost struct {
|
||||||
initial_backlog int // How many previous messages (maximum) to load when first joining a channel
|
initial_backlog int // How many previous messages (maximum) to load when first joining a channel
|
||||||
|
|
||||||
conn *matterclient.MMClient
|
conn *matterclient.MMClient
|
||||||
handlerStopChan chan bool
|
handlerStopChan chan struct{}
|
||||||
|
|
||||||
caches mmCaches
|
caches mmCaches
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func (mm *Mattermost) Configure(c Configuration) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reinitialize shared data structures
|
// Reinitialize shared data structures
|
||||||
mm.handlerStopChan = make(chan bool, 1)
|
mm.handlerStopChan = make(chan struct{})
|
||||||
|
|
||||||
mm.caches.mmusers = make(map[string]string)
|
mm.caches.mmusers = make(map[string]string)
|
||||||
mm.caches.sentjoined = make(map[string]bool)
|
mm.caches.sentjoined = make(map[string]bool)
|
||||||
|
@ -323,7 +323,7 @@ func (mm *Mattermost) Close() {
|
||||||
mm.conn.WsQuit = true
|
mm.conn.WsQuit = true
|
||||||
}
|
}
|
||||||
if mm.handlerStopChan != nil {
|
if mm.handlerStopChan != nil {
|
||||||
mm.handlerStopChan <- true
|
close(mm.handlerStopChan)
|
||||||
mm.handlerStopChan = nil
|
mm.handlerStopChan = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ func (mm *Mattermost) processBacklog(ch *model.Channel, backlog *model.PostList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mm *Mattermost) handleLoop(msgCh chan *matterclient.Message, quitCh chan bool) {
|
func (mm *Mattermost) handleLoop(msgCh chan *matterclient.Message, quitCh chan struct{}) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-quitCh:
|
case <-quitCh:
|
||||||
|
|
Loading…
Reference in a new issue