mirror of
https://github.com/soypat/lneto.git
synced 2026-08-12 10:53:44 +00:00
Stack backoff rework (#83)
* huge Stack backoff rework * lneto bump: huge Stack backoff rework
This commit is contained in:
@@ -79,7 +79,7 @@ func run(ctx context.Context, stack *xnet.StackAsync) error {
|
||||
// Other option is to instead use async API which leads to more verbose
|
||||
// and more stateful code.
|
||||
go stackLoop(ctx, stack)
|
||||
rstack := stack.StackRetrying(pollTime)
|
||||
rstack := stack.StackRetrying(stackBackoff)
|
||||
results, err := rstack.DoDHCPv4([4]byte{}, protoTimeout, protoRetries)
|
||||
if err != nil {
|
||||
return fmt.Errorf("doing DHCP: %w", err)
|
||||
@@ -93,7 +93,7 @@ func run(ctx context.Context, stack *xnet.StackAsync) error {
|
||||
return fmt.Errorf("resolving router MAC: %w", err)
|
||||
}
|
||||
stack.SetGateway6(gateway)
|
||||
berkstack := stack.StackBlocking(pollTime).StackGo(xnet.StackGoConfig{
|
||||
berkstack := stack.StackBlocking(stackBackoff).StackGo(xnet.StackGoConfig{
|
||||
ListenerPoolConfig: xnet.TCPPoolConfig{
|
||||
PoolSize: tcpConnPoolSize,
|
||||
QueueSize: tcpPacketQueueSize,
|
||||
@@ -171,3 +171,10 @@ func must(err error) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func stackBackoff(consecutiveBackoffs uint) time.Duration {
|
||||
if consecutiveBackoffs < 10 {
|
||||
return time.Millisecond
|
||||
}
|
||||
return 10 * time.Millisecond
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user