google / google/gopacket

pcap handle.Close() blocks for a long time

Open
#1,089 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.8k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

May be this is the same issue as #890

I have an ARP scanner that scans large /16 subnets. I send packets to each IP to see if it is live (65K IPs). The scan works fine but when I call handle.Close() the code blocks for about an hour before proceeding. Inspecting the goroutines looks like we are waiting on a mutex lock in handle.Close():
```go
handle, err := pcap.OpenLive(deviceName, 65536, true, pcap.BlockForever)
```
The problem is somewhat related to `pcap.BlockForever` because when I set my own timeout the Close() finishes successfully.
The total scan takes about 30 seconds and if I don't set a timeout to `pcap.OpenLive()` then I never finish the scan. I thought it never finished but when I left it running for a while it finished after 40-50 minutes. It was not doing anything just being stuck on the close. I thought this is something I did and debugged all my goroutine logic but it looks like the issue is in the `pcap.OpenLive()`. I can provide more code if needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.