Skip to content
This repository was archived by the owner on Dec 8, 2017. It is now read-only.

Commit 654aa68

Browse files
committed
Pass pointers instead of copies
1 parent bbae3b0 commit 654aa68

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

main.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
log.Println(err)
4949
continue
5050
}
51-
go proxy(conn, masterAddr, stopChan)
51+
go proxy(conn, masterAddr, &stopChan)
5252
}
5353
}
5454

@@ -76,8 +76,8 @@ func pipe(r io.Reader, w io.WriteCloser) {
7676
fmt.Println("Closing pipe")
7777
}
7878

79-
// pass a stopChan to the go routtine
80-
func proxy(local io.ReadWriteCloser, remoteAddr *net.TCPAddr, stopChan chan struct{}) {
79+
// pass a stopChan to the go routine
80+
func proxy(local io.ReadWriteCloser, remoteAddr *net.TCPAddr, stopChan *chan struct{}) {
8181
fmt.Printf("Opening a new connection on remoteAddr, %s\n", remoteAddr)
8282
remote, err := net.DialTCP("tcp", nil, remoteAddr)
8383
if err != nil {
@@ -87,7 +87,7 @@ func proxy(local io.ReadWriteCloser, remoteAddr *net.TCPAddr, stopChan chan stru
8787
}
8888
go pipe(local, remote)
8989
go pipe(remote, local)
90-
<-stopChan // read from stopChan
90+
<-*stopChan // read from stopChan
9191
fmt.Println("Closing Proxy")
9292
local.Close()
9393
}

0 commit comments

Comments
 (0)