mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Merge pull request #645 from safing/fix/nfq-shutdown
Fix shutting down nfq interception with go-nfqueue v1.3.1
This commit is contained in:
commit
82b44f4b3e
1 changed files with 8 additions and 0 deletions
|
@ -25,6 +25,7 @@ type Queue struct {
|
|||
nf atomic.Value
|
||||
packets chan pmpacket.Packet
|
||||
cancelSocketCallback context.CancelFunc
|
||||
canceled *abool.AtomicBool
|
||||
restart chan struct{}
|
||||
|
||||
pendingVerdicts uint64
|
||||
|
@ -50,6 +51,7 @@ func New(qid uint16, v6 bool) (*Queue, error) { //nolint:gocognit
|
|||
restart: make(chan struct{}, 1),
|
||||
packets: make(chan pmpacket.Packet, 1000),
|
||||
cancelSocketCallback: cancel,
|
||||
canceled: abool.New(),
|
||||
verdictCompleted: make(chan struct{}, 1),
|
||||
}
|
||||
|
||||
|
@ -142,6 +144,11 @@ func (q *Queue) handleError(e error) int {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if we have closed the queue already.
|
||||
if q.canceled.IsSet() {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Check if the queue was already closed. Unfortunately, the exposed error
|
||||
// variable is in an internal stdlib package. Therefore, check for the error
|
||||
// string instead. :(
|
||||
|
@ -222,6 +229,7 @@ func (q *Queue) Destroy() {
|
|||
return
|
||||
}
|
||||
|
||||
q.canceled.Set()
|
||||
q.cancelSocketCallback()
|
||||
|
||||
if nf := q.getNfq(); nf != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue