mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
yamux keep-alive config + remove write deadline for sub conns
This commit is contained in:
parent
767f868a36
commit
05b479e5fa
3 changed files with 13 additions and 6 deletions
|
@ -5,7 +5,8 @@ type configGetter interface {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
ListenAddrs []string `yaml:"listenAddrs"`
|
||||
WriteTimeoutSec int `yaml:"writeTimeoutSec"`
|
||||
DialTimeoutSec int `yaml:"dialTimeoutSec"`
|
||||
ListenAddrs []string `yaml:"listenAddrs"`
|
||||
WriteTimeoutSec int `yaml:"writeTimeoutSec"`
|
||||
DialTimeoutSec int `yaml:"dialTimeoutSec"`
|
||||
KeepAlivePeriodSec int `yaml:"keepAlivePeriodSec"`
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ func (y *yamuxConn) Open(ctx context.Context) (conn net.Conn, err error) {
|
|||
if conn, err = y.Session.Open(); err != nil {
|
||||
return
|
||||
}
|
||||
conn = connutil.NewTimeout(conn, time.Second*10)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -52,6 +51,5 @@ func (y *yamuxConn) Accept() (conn net.Conn, err error) {
|
|||
}
|
||||
return
|
||||
}
|
||||
conn = connutil.NewTimeout(conn, time.Second*10)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -51,8 +51,16 @@ func (y *yamuxTransport) Init(a *app.App) (err error) {
|
|||
if y.conf.WriteTimeoutSec <= 0 {
|
||||
y.conf.WriteTimeoutSec = 10
|
||||
}
|
||||
|
||||
y.yamuxConf = yamux.DefaultConfig()
|
||||
y.yamuxConf.EnableKeepAlive = false
|
||||
if y.conf.KeepAlivePeriodSec < 0 {
|
||||
y.yamuxConf.EnableKeepAlive = false
|
||||
} else {
|
||||
y.yamuxConf.EnableKeepAlive = true
|
||||
if y.conf.KeepAlivePeriodSec != 0 {
|
||||
y.yamuxConf.KeepAliveInterval = time.Duration(y.conf.KeepAlivePeriodSec) * time.Second
|
||||
}
|
||||
}
|
||||
y.yamuxConf.StreamOpenTimeout = time.Duration(y.conf.DialTimeoutSec) * time.Second
|
||||
y.yamuxConf.ConnectionWriteTimeout = time.Duration(y.conf.WriteTimeoutSec) * time.Second
|
||||
y.listCtx, y.listCtxCancel = context.WithCancel(context.Background())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue