mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-12 20:26:37 +08:00
fix(kcp): prevent zero-value override of window/buffer params causing 10x perf drop
The metadata parser unconditionally assigned GetInt results (which return 0 for missing keys) to all KCP config fields, overwriting defaults like SndWnd=1024, RcvWnd=1024, StreamBuf=2097152 with 0. KCP's WndSize only applies positive values, so snd_wnd=0 caused the write path condition waitsnd < s.kcp.snd_wnd to never succeed, effectively stalling throughput at ~10Mbps instead of 400Mbps+. - Only apply metadata values when the key actually exists (IsExists check) - Use Clone() instead of sharing the global DefaultConfig pointer - Add Config.Clone() deep-copy method
This commit is contained in:
@@ -89,6 +89,15 @@ func ParseFromFile(filename string) (*Config, error) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// Clone returns a deep copy of the Config.
|
||||
func (c *Config) Clone() *Config {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
clone := *c
|
||||
return &clone
|
||||
}
|
||||
|
||||
// Init initializes the KCP config.
|
||||
func (c *Config) Init() {
|
||||
switch c.Mode {
|
||||
|
||||
Reference in New Issue
Block a user