Skip to content

Commit

Permalink
Merge pull request #159 from remicorniere/close_keepalive
Browse files Browse the repository at this point in the history
Close keepalive when recv() ends in client.go
  • Loading branch information
remicorniere committed Mar 16, 2020
2 parents 64e5413 + d4960af commit ef6de60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,12 @@ func (c *Client) sendWithWriter(writer io.Writer, packet []byte) error {

// Loop: Receive data from server
func (c *Client) recv(keepaliveQuit chan<- struct{}) {
defer close(keepaliveQuit)

for {
val, err := stanza.NextPacket(c.transport.GetDecoder())
if err != nil {
c.ErrorHandler(err)
close(keepaliveQuit)
c.disconnected(c.Session.SMState)
return
}
Expand All @@ -392,7 +393,6 @@ func (c *Client) recv(keepaliveQuit chan<- struct{}) {
switch packet := val.(type) {
case stanza.StreamError:
c.router.route(c, val)
close(keepaliveQuit)
c.streamError(packet.Error.Local, packet.Text)
c.ErrorHandler(errors.New("stream error: " + packet.Error.Local))
// We don't return here, because we want to wait for the stream close tag from the server, or timeout.
Expand Down

0 comments on commit ef6de60

Please sign in to comment.