Arg, use
https://github.com/nhooyr/tlswrapd/blob/965c34913d5c8635b07ec8fb4918174298fa4855/proxy.go#L87-L110

On Sun, Oct 9, 2016 at 12:45 AM Anmol Sethi <an...@aubble.com> wrote:

> Ok, so I think I've got it really nice now:
> https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L87-L110
>
> Much simpler by only using the first error.
>
> On Sat, Oct 8, 2016 at 11:45 PM Anmol Sethi <an...@aubble.com> wrote:
>
> Sorry, my mistake. Use
> https://github.com/nhooyr/tlswrapd/blob/15b03321169039a4042434086d841a660a7afd88/proxy.go#L88-L143
>  as
> the link incase I change things and the line numbers become incorrect.
>
> On Sat, Oct 8, 2016 at 11:43 PM Anmol Sethi <an...@aubble.com> wrote:
>
> My TLS proxy used to create two goroutines of `io.Copy` to copy between
> the incoming and outgoing connection.
>
> As soon as `io.Copy` returned, with or without an error, I closed both
> connections. This had the effect that on the other goroutine, the
> Read/Write returned with errors about the "use of a closed network
> connection".
>
> In order to prevent the errors, I used context.Context like this:
> https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L88-L143
>
> Several things I am unsure about now. First, I feel like I am misusing
> context.Context. Second, should I even bother synchronizing everything
> myself? As in, should I just have a channel with a single buffer where the
> first error is sent and then only print that and assume the other error is
> a result from closing the connections?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to