Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/gcla/termshark/v2
go 1.13

require (
github.com/Jille/contextcond v1.0.0
github.com/adam-hanna/arrayOperations v0.2.6
github.com/antchfx/xmlquery v1.3.3
github.com/antchfx/xpath v1.1.11 // indirect
Expand All @@ -29,7 +30,6 @@ require (
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.7.1
github.com/tevino/abool v1.2.0
gitlab.com/jonas.jasas/condchan v0.0.0-20190210165812-36637ad2b5bc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Jille/contextcond v1.0.0 h1:MI7hdTKyS6CLc5DIJmyjN8iEfw7/e8HJ5ZOwTJpS9SI=
github.com/Jille/contextcond v1.0.0/go.mod h1:aWoovvPMcWinBsm69wTnhSrCwTGtCfg4xr4Nku8WgIg=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/adam-hanna/arrayOperations v0.2.6 h1:QZC99xC8MgUawXnav7bFMejs/dm7YySnDpMx3oZzz2Y=
Expand Down Expand Up @@ -534,8 +536,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
gitlab.com/jonas.jasas/condchan v0.0.0-20190210165812-36637ad2b5bc h1:zCsu+odZEHb2f8U8WWhDgY5N5w3JCLHxuCIqVqCsLcQ=
gitlab.com/jonas.jasas/condchan v0.0.0-20190210165812-36637ad2b5bc/go.mod h1:4JS8TdA7HSdK+x43waOdTGodqY/VKsj4w+8pWDL0E88=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
Expand Down
23 changes: 9 additions & 14 deletions ui/searchbyfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strconv"
"sync"

"github.com/Jille/contextcond"
"github.com/gcla/gowid"
"github.com/gcla/gowid/widgets/table"
"github.com/gcla/termshark/v2"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/gcla/termshark/v2/pkg/pcap"
"github.com/gcla/termshark/v2/widgets/search"
log "github.com/sirupsen/logrus"
"gitlab.com/jonas.jasas/condchan"
)

//======================================================================
Expand Down Expand Up @@ -57,7 +57,7 @@ type filterSearchState struct {
pcapInfo os.FileInfo

// To protect below:
cc *condchan.CondChan
cc *contextcond.Cond

// State covered by cc and ccMtx
first int // first packet found; from here, jump into nextMap
Expand All @@ -82,7 +82,7 @@ func newFilterSearchState(filename string, cmd pcap.IPcapCommand) (*filterSearch
cancelFn: cancelFn,
pcapInfo: info,
}
res.cc = condchan.New(&sync.Mutex{})
res.cc = contextcond.NewCond(&sync.Mutex{})
return res, nil
}

Expand Down Expand Up @@ -293,17 +293,12 @@ Loop:
}

if !mpval.finished {
mpval.cc.Select(func(c <-chan struct{}) { // Waiting with select
// Either of these two channels mean we should proceed. The first
// means that some search state has changed - maybe a new result,
// maybe a cancellation, maybe the end of the process execution. The
// second means something else interrupted - e.g. user hit the stop
// button.
select {
case <-c:
case <-mpval.ctx.Done():
}
})
// Either a Broadcast or context cancellation means we should proceed.
// The first means that some search state has changed - maybe a new
// result, maybe a cancellation, maybe the end of the process
// execution. The second means something else interrupted - e.g. user
// hit the stop button.
_ = mpval.cc.WaitContext(mpval.ctx)
}
}
}
Expand Down