Barf gross hack so the waitgroup doesn't wait forever FIXME
This commit is contained in:
parent
899e425e76
commit
0434070a35
|
@ -6,11 +6,13 @@ import (
|
|||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/tcpassembly"
|
||||
"github.com/dirtbags/netshovel"
|
||||
)
|
||||
|
||||
var threads int
|
||||
var wg sync.WaitGroup
|
||||
|
||||
type SimpleStreamFactory struct {
|
||||
|
@ -34,6 +36,7 @@ func (f *SimpleStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stre
|
|||
stream := &SimpleStream{
|
||||
Stream: netshovel.NewStream(net, transport),
|
||||
}
|
||||
threads += 1
|
||||
wg.Add(1)
|
||||
go stream.Decode(wg)
|
||||
|
||||
|
@ -52,7 +55,6 @@ func (stream SimpleStream) Display(pkt SimplePacket) {
|
|||
}
|
||||
|
||||
func (stream SimpleStream) Decode(wg sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
for {
|
||||
pkt := NewSimplePacket()
|
||||
|
||||
|
@ -69,9 +71,17 @@ func (stream SimpleStream) Decode(wg sync.WaitGroup) {
|
|||
pkt.When = utterance.When
|
||||
stream.Display(pkt)
|
||||
}
|
||||
threads -= 1
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
func main() {
|
||||
threads = 0
|
||||
netshovel.Shovel(&SimpleStreamFactory{})
|
||||
wg.Wait()
|
||||
|
||||
// XXX: ZOMG WHY
|
||||
for threads > 0 {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
//wg.Wait()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue