Skip to content

Commit

Permalink
randomly wait to prevent message storm
Browse files Browse the repository at this point in the history
  • Loading branch information
monnand committed Jun 29, 2014
1 parent 21f4735 commit 0d7b936
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion srv/apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ func (self *apnsPushService) singlePush(payload, token []byte, expiry uint32, mi
conn.Close()

time.Sleep(sleepTime)
sleepTime = sleepTime * 2
// randomly wait more time
sleepTime += time.Duration(rand.Int63n(int64(sleepTime)))
// Let's try another connection to see if we can recover this error
conn, err = pool.Get()

Expand Down

0 comments on commit 0d7b936

Please sign in to comment.