Use alternative approach to fix nfqueue closing process

This commit reverts commit ec6a3f03e8.
This commit is contained in:
Daniel 2022-05-18 09:34:27 +02:00
parent e953bc7f3f
commit 932f6002b4

View file

@ -25,7 +25,6 @@ type Queue struct {
nf atomic.Value
packets chan pmpacket.Packet
cancelSocketCallback context.CancelFunc
canceled *abool.AtomicBool
restart chan struct{}
pendingVerdicts uint64
@ -51,7 +50,6 @@ 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),
}
@ -144,11 +142,6 @@ 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. :(
@ -160,7 +153,8 @@ func (q *Queue) handleError(e error) int {
// Close the existing socket
if nf := q.getNfq(); nf != nil {
_ = nf.Close()
// Call Close() on the Con directly, as nf.Close() calls waitgroup.Wait(), which then may deadlock.
_ = nf.Con.Close()
}
// Trigger a restart of the queue
@ -229,7 +223,6 @@ func (q *Queue) Destroy() {
return
}
q.canceled.Set()
q.cancelSocketCallback()
if nf := q.getNfq(); nf != nil {