stopCapture doesn't come out when no packets

22 views
Skip to first unread message

chetan kumar

unread,
May 17, 2021, 6:46:48 AM5/17/21
to PcapPlusPlus support
Hello,

we are using the API:
PcapLiveDevice ::  startCapture(pcpp::OnPacketArrivesCallback onPacketArrives, void *onPacketArrivesUserCookie); 
to  start the capture on an interface with a custom Filter.

however, during termination, when we invoke  PcapLiveDevice :: stopCapture(), the function gets stuck and doesn't come out, when there are no packets to read (the packets that match the applied filter).

it looks like, the background thread which is calling pcap_dispatch() in function PcapLiveDevice::captureThreadMain(), is stuck and doesn't come out.

i understand that, pcap provides a way to break the loop of reading packets, i.e. pcap_breakloop() API, however i see that this API is not used in pcapplusplus.

how do you propose we handle this scenario?

regards
Chetan

chetan kumar

unread,
May 29, 2021, 4:50:39 AM5/29/21
to PcapPlusPlus support
Hi,

Any update on this question?

Regards
Chetan

PcapPlusPlus Support

unread,
May 31, 2021, 4:38:43 AM5/31/21
to chetan kumar, PcapPlusPlus support
Hi Chetan,

I'm sorry for the late reply, I probably missed this question somehow.
That's an interesting idea, I  implemented it a long time ago and I'm not sure why I didn't try calling `pcap_breakloop()`.
Would you consider trying to call it and see if it works? If it does, maybe you can open a PR with the fix?

Thanks,
PcapPlusPlus maintainer


--
You received this message because you are subscribed to the Google Groups "PcapPlusPlus support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pcapplusplus-sup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pcapplusplus-support/051f2a28-6345-4e2d-a684-843e1739b0c7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages