You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the proxy code and noticed that the current implementation makes it slightly hard to propagate context cancellation through the proxy.Run() function. I've temporarily addressed this issue by using error groups and calling proxy.Close():
eg.Go(func() error {
<-ctx.Done()
proxy.Close()
return ctx.Err()
})
eg.Go(func() error {
if err := s.proxy.Run(); err != nil {
// If context has been cancelled, terminate goroutine and return no error.
if ctx.Err() != nil {
return nil
}
return err
}
return nil
})
However, this created a raciness issue which eventually led me to creating a SafeProxy type that wrapped the proxy with a mutex:
i.e.
type SafeProxy struct {
mu sync.Mutex
proxy *tcpproxy.Proxy
}
However, if the original Run or Wait functions were to actually take a context (i.e. proxy.Run(ctx) or proxy.Wait(ctx), that would make it easy to gracefully terminate the proxy.
I'm also happy to work on a PR to implement this if there is any interest!
The text was updated successfully, but these errors were encountered:
Using the proxy code and noticed that the current implementation makes it slightly hard to propagate context cancellation through the proxy.Run() function. I've temporarily addressed this issue by using error groups and calling proxy.Close():
However, this created a raciness issue which eventually led me to creating a SafeProxy type that wrapped the proxy with a mutex:
i.e.
However, if the original Run or Wait functions were to actually take a context (i.e.
proxy.Run(ctx) or proxy.Wait(ctx)
, that would make it easy to gracefully terminate the proxy.I'm also happy to work on a PR to implement this if there is any interest!
The text was updated successfully, but these errors were encountered: