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

Commit

Permalink
Merge pull request #54 from openfresh/feature/fix_close_channel_panic
Browse files Browse the repository at this point in the history
fixed panic to send closed channel
  • Loading branch information
stormcat24 authored Jul 7, 2017
2 parents a0625ee + 32aeb37 commit 4a14ebe
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 4a14ebe

Please sign in to comment.