Created
January 28, 2013 18:20
-
-
Save asergeyev/4657796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/client.go b/client.go | |
index 7842cfc..a12f4ba 100644 | |
--- a/client.go | |
+++ b/client.go | |
@@ -47,6 +47,7 @@ func (c *Client) Exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err erro | |
if err = w.dial(); err != nil { | |
return nil, 0, err | |
} | |
+ defer w.close() | |
if err = w.send(m); err != nil { | |
return nil, 0, err | |
} | |
@@ -267,6 +268,10 @@ func (w *reply) write(p []byte) (n int, err error) { | |
return | |
} | |
+func (w *reply) close() { | |
+ w.conn.Close() | |
+} | |
+ | |
func setTimeouts(w *reply) { | |
if w.client.ReadTimeout == 0 { | |
w.conn.SetReadDeadline(time.Now().Add(2 * 1e9)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment