[Winpcap-users] Thread safety of pcap_dump_close ?

Guy Harris guy at alum.mit.edu
Sun Nov 20 10:32:36 GMT 2005


Noam Dev wrote:

> What might 
> happen (probably does) is that pcap_dump_close is called with the old 
> pcap_dumper while the capturing thread is still using it in the middle 
> of a pcap_dispatch call. The question is, is there a lock that will wait 
> until the call finishes

No.

> or do i need to implement my own?

Yes (unless you make newDumpFile global and have 
PcapInstance::setDumpFile() just open the new file and set newDumpFile, 
and have the code in the capturing thread check for a non-null 
newDumpFile and, if it sees it's non-null, close dumpFile, set dumpFile 
to newDumpFile, and null out newDumpFile).

(This isn't exactly "wrapping" pcap - it's adding a new layer of 
functionality, namely a capture loop (presumably) and a function to 
switch output files.)


More information about the Winpcap-users mailing list