4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-07-03 08:27:47 +00:00

fix core_test.go and a race in setting/using mtu

This commit is contained in:
Arceliar
2021-06-13 13:40:20 -05:00
parent cb81be94ec
commit b34c3230f8
3 changed files with 33 additions and 13 deletions

View File

@ -243,16 +243,20 @@ func (c *Core) MaxMTU() uint64 {
return c.store.maxSessionMTU()
}
// SetMTU can only safely be called after Init and before Start.
func (c *Core) SetMTU(mtu uint64) {
if mtu < 1280 {
mtu = 1280
}
c.store.mutex.Lock()
c.store.mtu = mtu
c.store.mutex.Unlock()
}
func (c *Core) MTU() uint64 {
return c.store.mtu
c.store.mutex.Lock()
mtu := c.store.mtu
c.store.mutex.Unlock()
return mtu
}
// Implement io.ReadWriteCloser