mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
keep a context in the core, use it for listen/dial, cancel it when closing
This commit is contained in:
parent
3815b13ad5
commit
5b6f730f18
2 changed files with 15 additions and 8 deletions
|
@ -153,7 +153,7 @@ func (t *tcp) listenURL(u *url.URL, sintf string) (*TcpListener, error) {
|
|||
func (t *tcp) listen(listenaddr string, upgrade *TcpUpgrade) (*TcpListener, error) {
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
ctx := t.links.core.ctx
|
||||
lc := net.ListenConfig{
|
||||
Control: t.tcpContext,
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ func (t *tcp) call(saddr string, options tcpOptions, sintf string) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx, done := context.WithTimeout(context.Background(), default_timeout)
|
||||
ctx, done := context.WithTimeout(t.links.core.ctx, default_timeout)
|
||||
conn, err = dialer.(proxy.ContextDialer).DialContext(ctx, "tcp", saddr)
|
||||
done()
|
||||
if err != nil {
|
||||
|
@ -339,7 +339,7 @@ func (t *tcp) call(saddr string, options tcpOptions, sintf string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ctx, done := context.WithTimeout(context.Background(), default_timeout)
|
||||
ctx, done := context.WithTimeout(t.links.core.ctx, default_timeout)
|
||||
conn, err = dialer.DialContext(ctx, "tcp", dst.String())
|
||||
done()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue