Merge remote-tracking branch 'upstream/master' into 67_attach
Conflicts: pcap.go
This commit is contained in:
commit
57ad2cbeaf
3 files changed
+11
-5
No files matched your search
+2
-3
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
@@ -59,7 +58,7 @@ func (cm *ConnectionMaker) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteraction) {
|
func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteraction) {
|
||||||
timer := time.NewTimer(math.MaxInt64)
|
timer := time.NewTimer(MaxDuration)
|
||||||
run := func() { timer.Reset(cm.checkStateAndAttemptConnections()) }
|
run := func() { timer.Reset(cm.checkStateAndAttemptConnections()) }
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@@ -131,7 +130,7 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration {
|
|||||||
})
|
})
|
||||||
|
|
||||||
now := time.Now() // make sure we catch items just added
|
now := time.Now() // make sure we catch items just added
|
||||||
after := time.Duration(math.MaxInt64)
|
after := MaxDuration
|
||||||
for address, target := range cm.targets {
|
for address, target := range cm.targets {
|
||||||
if our_connected_targets[address] {
|
if our_connected_targets[address] {
|
||||||
delete(cm.targets, address)
|
delete(cm.targets, address)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package weave
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -23,6 +24,7 @@ const (
|
|||||||
FragTestInterval = 5 * time.Minute
|
FragTestInterval = 5 * time.Minute
|
||||||
PMTUVerifyAttempts = 8
|
PMTUVerifyAttempts = 8
|
||||||
PMTUVerifyTimeout = 10 * time.Millisecond // gets doubled with every attempt
|
PMTUVerifyTimeout = 10 * time.Millisecond // gets doubled with every attempt
|
||||||
|
MaxDuration = time.Duration(math.MaxInt64)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func newPcapIO(ifName string, promisc bool, snaplen int, bufSz int) (handle *Pca
|
|||||||
if err = inactive.SetSnapLen(snaplen); err != nil {
|
if err = inactive.SetSnapLen(snaplen); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = inactive.SetTimeout(-1); err != nil {
|
if err = inactive.SetTimeout(MaxDuration); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = inactive.SetImmediateMode(true); err != nil {
|
if err = inactive.SetImmediateMode(true); err != nil {
|
||||||
@@ -60,7 +60,12 @@ func newPcapIO(ifName string, promisc bool, snaplen int, bufSz int) (handle *Pca
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pi *PcapIO) ReadPacket() (data []byte, err error) {
|
func (pi *PcapIO) ReadPacket() (data []byte, err error) {
|
||||||
data, _, err = pi.handle.ZeroCopyReadPacketData()
|
for {
|
||||||
|
data, _, err = pi.handle.ZeroCopyReadPacketData()
|
||||||
|
if err == nil || err != pcap.NextErrorTimeoutExpired {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user