This commit is contained in:
crusader 2018-09-05 04:12:14 +09:00
parent 7535e7ffc1
commit dee29f34d9
8 changed files with 17 additions and 27 deletions

View File

@ -98,14 +98,17 @@ func (d *ofDiscoverer) enqueue(req *ofDiscoveryRequest) {
go func() {
select {
case <-req.dequeue:
case <-time.After(10 * time.Second):
case <-time.After(20 * time.Second):
req.timeout = true
d.SendMessage(req, types.DiscoveryMessageTypeTimeout, omu.Now(), nil)
req.release()
}
}()
default:
d.SendMessage(req, types.DiscoveryMessageTypeFailedQueueing, omu.Now(), nil)
select {
case <-time.After(time.Microsecond * 500):
}
req.release()
}
}
@ -123,6 +126,7 @@ LOOP:
return
}
if req.(*ofDiscoveryRequest).timeout {
req.(*ofDiscoveryRequest).release()
continue LOOP
}
req.(*ofDiscoveryRequest).dequeue <- true
@ -136,12 +140,12 @@ LOOP:
session.ReleaseDiscoverySession(s)
timer := time.NewTimer(time.Millisecond * 500)
select {
case <-timer.C:
}
req.(*ofDiscoveryRequest).release()
select {
case <-time.After(time.Second * 1):
}
log.Print("Discovery Session complete")
case <-d.stopChan:
return

View File

@ -103,10 +103,8 @@ func sendARP(ps pcap.PCapScanner, zone *omd.Zone, targetHosts []net.IP) error {
return err
}
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
}
}

View File

@ -105,10 +105,8 @@ LOOP:
continue LOOP
}
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
}
}

View File

@ -104,10 +104,8 @@ LOOP:
continue LOOP
}
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
}
}

View File

@ -56,10 +56,8 @@ Loop:
tryConnect(discoverySession, ports, targetHost, port, timeout, stopChan)
}(portNumber)
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
case <-discoverySession.StopChan():
close(stopChan)
return nil

View File

@ -109,10 +109,8 @@ Loop:
return err
}
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
case <-stopChan:
return nil
}

View File

@ -56,10 +56,8 @@ Loop:
tryConnect(discoverySession, ports, targetHost, port, timeout, stopChan)
}(portNumber)
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
case <-discoverySession.StopChan():
close(stopChan)
return nil

View File

@ -116,10 +116,8 @@ func sendUDP4(discoverySession session.DiscoverySession, ps pcap.PCapScanner, ho
}
}
timer := time.NewTimer(time.Microsecond * 100)
select {
case <-timer.C:
case <-time.After(time.Microsecond * 100):
}
}
}