Browse Source

Fix: don't count EOF conditions as port forward failures

Rod Hynes 11 years ago
parent
commit
ceafbb5b63
1 changed files with 3 additions and 2 deletions
  1. 3 2
      psiphon/controller.go

+ 3 - 2
psiphon/controller.go

@@ -26,6 +26,7 @@ package psiphon
 import (
 	"errors"
 	"fmt"
+	"io"
 	"log"
 	"net"
 	"os"
@@ -417,7 +418,7 @@ type TunneledConn struct {
 
 func (conn *TunneledConn) Read(buffer []byte) (n int, err error) {
 	n, err = conn.Conn.Read(buffer)
-	if err != nil {
+	if err != nil && err != io.EOF {
 		// Report 1 new failure. Won't block; assumes the receiver
 		// has a sufficient buffer for the threshold number of reports.
 		// TODO: conditional on type of error or error message?
@@ -431,7 +432,7 @@ func (conn *TunneledConn) Read(buffer []byte) (n int, err error) {
 
 func (conn *TunneledConn) Write(buffer []byte) (n int, err error) {
 	n, err = conn.Conn.Write(buffer)
-	if err != nil {
+	if err != nil && err != io.EOF {
 		// Same as TunneledConn.Read()
 		select {
 		case conn.tunnel.portForwardFailures <- 1: