Close tears down the WinDivert handle and stops the recv loop.
()
| 188 | |
| 189 | // Close tears down the WinDivert handle and stops the recv loop. |
| 190 | func (b *Backend) Close() error { |
| 191 | b.mu.Lock() |
| 192 | if !b.opened { |
| 193 | b.mu.Unlock() |
| 194 | return nil |
| 195 | } |
| 196 | b.opened = false |
| 197 | select { |
| 198 | case <-b.closed: |
| 199 | default: |
| 200 | close(b.closed) |
| 201 | } |
| 202 | h := b.handle |
| 203 | b.handle = invalidHandle |
| 204 | b.mu.Unlock() |
| 205 | |
| 206 | var firstErr error |
| 207 | if h != invalidHandle { |
| 208 | if err := Close(h); err != nil { |
| 209 | firstErr = err |
| 210 | } |
| 211 | } |
| 212 | b.reader.Wait() |
| 213 | return firstErr |
| 214 | } |
nothing calls this directly
no test coverage detected