[Pkg-privacy-commits] [obfs4proxy] 13/151: Log and propagate errors between the 2 goroutines in copyLoop.

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 c3acefb7e5aa5ef4cd65fc77ad4caa917efda130
Author: Yawning Angel <yawning at schwanenlied.me>
Date:   Mon May 12 05:08:04 2014 +0000

    Log and propagate errors between the 2 goroutines in copyLoop.
    
    This fixes #1.
---
 obfs4proxy/obfs4proxy.go | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index dc0c2bc..34027fc 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -81,11 +81,21 @@ func copyLoop(a, b net.Conn) {
 
 	// XXX: Log/propagate errors.
 	go func() {
-		io.Copy(b, a)
+		_, err := io.Copy(b, a)
+		if err != nil {
+			b.Close()
+			a.Close()
+			log.Printf("[WARN] Connection closed: %s", err)
+		}
 		wg.Done()
 	}()
 	go func() {
-		io.Copy(a, b)
+		_, err := io.Copy(a, b)
+		if err != nil {
+			a.Close()
+			b.Close()
+			log.Printf("[WARN] Connection closed: %s", err)
+		}
 		wg.Done()
 	}()
 
@@ -115,7 +125,7 @@ func serverHandler(conn net.Conn, info *pt.ServerInfo) error {
 	}
 	defer or.Close()
 
-	copyLoop(conn, or)
+	copyLoop(or, conn)
 
 	return nil
 }

-- 
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