[Pkg-privacy-commits] [obfs4proxy] 17/151: Fix copyLoop to break out the other goroutine on graceful exit.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:59:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfs4proxy.

commit d2b2e383fdc55424d4df7516677670d2b961309b
Author: Yawning Angel <yawning at schwanenlied.me>
Date:   Tue May 13 03:19:55 2014 +0000

    Fix copyLoop to break out the other goroutine on graceful exit.
    
    This should fix sockets getting stuck in CLOSE_WAIT.
---
 obfs4proxy/obfs4proxy.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index 42a6740..255bdf1 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -88,22 +88,22 @@ func copyLoop(a, b net.Conn) {
 	go func() {
 		defer logAndRecover()
 		defer wg.Done()
+		defer b.Close()
+		defer a.Close()
 
 		_, err := io.Copy(b, a)
 		if err != nil {
-			b.Close()
-			a.Close()
 			log.Printf("[WARN] Connection closed: %s", err)
 		}
 	}()
 	go func() {
 		defer logAndRecover()
 		defer wg.Done()
+		defer a.Close()
+		defer b.Close()
 
 		_, err := io.Copy(a, b)
 		if err != nil {
-			a.Close()
-			b.Close()
 			log.Printf("[WARN] Connection closed: %s", err)
 		}
 	}()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfs4proxy.git



More information about the Pkg-privacy-commits mailing list