Apns4r
Apns4r copied to clipboard
APNs4r::Sender can enter infinite loop. Yikes!
In APNs4r::Sender#push, if @ssl.write fails there are two bugs in the rescue block:
- The ssl connection is not recreated, since @ssl ||= connect is used rather than @ssl = connect.
- If the write fails again (e.g. because ssl has disconnected, but isn't nil), retry will be call an infinite number of times.
here's quick-and-dirty fix with exponential delay and total timeout def push notification delay = 2 begin @ssl.write notification.to_s rescue OpenSSL::SSL::SSLError, Errno::EPIPE sleep delay @ssl = connect(@host, @port) delay*=2 and retry if delay < 60 raise Timeout::Error end end
tell me if it's fit you needs and i'll push it.
Yes, that looks good -- thanks!