-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Potential) race condition on close #3
Comments
Also while I'm at it, add documentation to attempt to read from the error channel for a bit after calling Disconnect() |
hey, any update on this? i've having an issue where thanks for your hard work |
note that the error code is for {
fmt.Println("NEW CONNECTION")
apnsConn, _ := apns.NewAPNSConnection(&apns.APNSConfig{
CertificateBytes: certPem,
KeyBytes: keyPem,
})
loop:
for {
select {
case <-closing:
apnsConn.Disconnect()
return
case closeError := <-apnsConn.CloseChannel:
fmt.Println("ERROR !!!")
fmt.Println(closeError.Error.ErrorCode)
fmt.Println(closeError.UnsentPayloads.Len())
break loop
case p := <-c:
apnsConn.SendChannel <- p
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When Disconnect() is called, all that happens is the in flight buffer gets locked and then the socket is closed. The problem is if this is used in a multithreaded environment and there are any unsent payloads outside of the inflight buffer after Disconnect is called, the inflight buffer will never be flushed and there's a potential to lose whatever payload was being added as the connection was closed.
Probably just need to add an extra conditional here (https://github.com/joekarl/go-libapns/blob/master/connection.go#L299-L309) so that if the connection closed without an apple error, we return the unsent payload(s).
The text was updated successfully, but these errors were encountered: