mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
use SO_RCVBUFFORCE to force receive buffer increase on Linux (#3804)
* Add ability to force change the receive buffer size using SO_RCVBUFFORCE in Linux * Fix imports * Update test * Add sys_conn_helper_not_linux * Rename file * ignore the error on SetReadBuffer * also run unit tests as root --------- Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
parent
da198b710b
commit
843b633434
5 changed files with 90 additions and 5 deletions
|
@ -2,7 +2,13 @@
|
|||
|
||||
package quic
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const msgTypeIPTOS = unix.IP_TOS
|
||||
|
||||
|
@ -17,3 +23,23 @@ const (
|
|||
)
|
||||
|
||||
const batchSize = 8 // needs to smaller than MaxUint8 (otherwise the type of oobConn.readPos has to be changed)
|
||||
|
||||
func forceSetReceiveBuffer(c interface{}, bytes int) error {
|
||||
conn, ok := c.(interface {
|
||||
SyscallConn() (syscall.RawConn, error)
|
||||
})
|
||||
if !ok {
|
||||
return errors.New("doesn't have a SyscallConn")
|
||||
}
|
||||
rawConn, err := conn.SyscallConn()
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't get syscall.RawConn: %w", err)
|
||||
}
|
||||
var serr error
|
||||
if err := rawConn.Control(func(fd uintptr) {
|
||||
serr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUFFORCE, bytes)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return serr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue