Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
fixed panic to send closed channel
Browse files Browse the repository at this point in the history
  • Loading branch information
stormcat24 committed Jul 7, 2017
1 parent a0625ee commit 32aeb37
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion manager/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (cm *ClientManager) SendPayload(payload event.Payload) {
wg2.Add(1)
go func(client chan event.Payload) {
defer wg2.Done()
client <- payload
sendPayloadSafety(client, payload)
}(client)
}
wg2.Wait()
Expand All @@ -119,6 +119,16 @@ func (cm *ClientManager) SendPayload(payload event.Payload) {
wg.Wait()
}

func sendPayloadSafety(client chan event.Payload, payload event.Payload) {
defer func() {
if err := recover(); err != nil {
return
}
}()
client <- payload
return
}

const heartBeatEvent = "heartbeat"

func (cm *ClientManager) SendHeartBeat() {
Expand Down

0 comments on commit 32aeb37

Please sign in to comment.