From f94896a294ec1723dfc11efc3702ccd1fa6bb674 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Thu, 19 Jul 2018 10:02:41 +0800 Subject: [PATCH] prevent multiple call Run --- conn.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conn.go b/conn.go index 9793eff..0dd5090 100644 --- a/conn.go +++ b/conn.go @@ -27,6 +27,7 @@ type Conn struct { streamCount int closed bool isServer bool + running bool handler http.Handler lock *sync.Mutex err error @@ -227,6 +228,10 @@ func (c *Conn) Connect(addr string) (net.Conn, int, error) { // Run run the event loop func (c *Conn) Run() { + if c.running { + return + } + c.running = true defer c.Close() go c.readloop()