mirror of https://github.com/slackhq/nebula.git
*WIP* this is just test code but works to increase throughput on windows
significantly. the default windows buffers are 8192KB which is :(
This commit is contained in:
parent
ea07a89cc8
commit
6dea7760cb
|
@ -11,6 +11,32 @@ import (
|
|||
func NewListenConfig(multi bool) net.ListenConfig {
|
||||
return net.ListenConfig{
|
||||
Control: func(network, address string, c syscall.RawConn) error {
|
||||
var controlErr error
|
||||
err := c.Control(func(fd uintptr) {
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 999999); err != nil {
|
||||
controlErr = fmt.Errorf("SO_SNDBUF failed: %v", err)
|
||||
return
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if controlErr != nil {
|
||||
return controlErr
|
||||
}
|
||||
err = c.Control(func(fd uintptr) {
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 999999); err != nil {
|
||||
controlErr = fmt.Errorf("SO_RCVBUF failed: %v", err)
|
||||
return
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if controlErr != nil {
|
||||
return controlErr
|
||||
}
|
||||
|
||||
if multi {
|
||||
// There is no way to support multiple listeners safely on Windows:
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/winsock/using-so-reuseaddr-and-so-exclusiveaddruse
|
||||
|
|
Loading…
Reference in New Issue