Commit f85c2550cbd43d13855d929ac89a1ff6bae9c2b6

Parents: 5504ce7393dc1b1b74d33657bd5a1abaeb702681

From: Moritz Poldrack <git@moritz.sh>
Date: Mon Jun 13 22:52:21 2022 +0700

fixed lockup in Close

		

Stats

conn.go +3/-11

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/conn.go b/conn.go
index cfd7d3f519b7aa743fe0d63f418588e3d307ab29..bbd76edbe19bc81b821fe25c1430be2eb1949ea6 100644
--- a/conn.go
+++ b/conn.go
@@ -94,20 +94,12 @@ func (c *Conn) Close(ctx context.Context) error {
 	c.cancel()
 	defer c.c.Close()
 
-	origCtx := c.ctx
-	defer func() { c.ctx = origCtx }()
-	c.ctx = ctx
-
-	resp, err := c.CmdNoBody(ctx, "QUIT")
+	_, err := c.c.Cmd("QUIT")
 	if err != nil {
 		return fmt.Errorf("failed to send QUIT to server: %w", err)
 	}
-	switch resp.Status.Code {
-	case StatusConnectionClosing:
-		return nil
-	default:
-		return ErrUnexpectedResponse
-	}
+
+	return nil
 }
 
 // Cmd runs a command on the given connection and does not parse headers