commit b0a20051b814cc9115926f32f5d1b11bb081cd18 Author: David Fifield david@bamsoftware.com Date: Sat Dec 14 21:15:41 2013 -0800
Close listeners after acceptLoop. --- examples/dummy-client/dummy-client.go | 1 + examples/dummy-server/dummy-server.go | 1 + pt.go | 2 ++ 3 files changed, 4 insertions(+)
diff --git a/examples/dummy-client/dummy-client.go b/examples/dummy-client/dummy-client.go index 01d843b..e1cede5 100644 --- a/examples/dummy-client/dummy-client.go +++ b/examples/dummy-client/dummy-client.go @@ -67,6 +67,7 @@ func handler(conn *pt.SocksConn) error { }
func acceptLoop(ln *pt.SocksListener) error { + defer ln.Close() for { conn, err := ln.AcceptSocks() if err != nil { diff --git a/examples/dummy-server/dummy-server.go b/examples/dummy-server/dummy-server.go index d9fd5f8..94b7bb6 100644 --- a/examples/dummy-server/dummy-server.go +++ b/examples/dummy-server/dummy-server.go @@ -64,6 +64,7 @@ func handler(conn net.Conn) error { }
func acceptLoop(ln net.Listener) error { + defer ln.Close() for { conn, err := ln.Accept() if err != nil { diff --git a/pt.go b/pt.go index f58edbc..391b1f5 100644 --- a/pt.go +++ b/pt.go @@ -19,6 +19,7 @@ // return nil // } // func acceptLoop(ln *pt.SocksListener) error { +// defer ln.Close() // for { // conn, err := ln.AcceptSocks() // if err != nil { @@ -64,6 +65,7 @@ // return nil // } // func acceptLoop(ln net.Listener) error { +// defer ln.Close() // for { // conn, err := ln.Accept() // if err != nil {