[tor-commits] [websocket/master] Check the type of accept errors and close listeners explicitly.
dcf at torproject.org
dcf at torproject.org
Sun Dec 15 05:53:55 UTC 2013
commit a656ff02d15ebc8c1cf937d94c1a6ad9bbdcb038
Author: David Fifield <david at bamsoftware.com>
Date: Sat Dec 14 21:53:32 2013 -0800
Check the type of accept errors and close listeners explicitly.
---
websocket-client/websocket-client.go | 6 +++++-
websocket-server/websocket-server.go | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/websocket-client/websocket-client.go b/websocket-client/websocket-client.go
index d1d6dcc..228cb1c 100644
--- a/websocket-client/websocket-client.go
+++ b/websocket-client/websocket-client.go
@@ -152,10 +152,14 @@ func handleConnection(conn *pt.SocksConn) error {
}
func socksAcceptLoop(ln *pt.SocksListener) error {
+ defer ln.Close()
for {
socks, err := ln.AcceptSocks()
if err != nil {
- return err
+ if e, ok := err.(*net.OpError); ok && !e.Temporary() {
+ return err
+ }
+ continue
}
go func() {
err := handleConnection(socks)
diff --git a/websocket-server/websocket-server.go b/websocket-server/websocket-server.go
index 84b5e5c..64ae7b4 100644
--- a/websocket-server/websocket-server.go
+++ b/websocket-server/websocket-server.go
@@ -192,6 +192,7 @@ func startListener(addr *net.TCPAddr) (*net.TCPListener, error) {
return nil, err
}
go func() {
+ defer ln.Close()
var config websocket.Config
config.Subprotocols = []string{"base64"}
config.MaxMessageSize = maxMessageSize
More information about the tor-commits
mailing list