[Winpcap-users] Thread safety of pcap_dump_close ?

Noam Dev noamdev at gmail.com
Sun Nov 20 06:36:14 GMT 2005


 I'm wrapping pcap for use in .net (using framework 2.0) and i have this
function :
 void PcapInstance::setDumpFile(char* dumpFileStr)
{
 pcap_dumper_t* oldDumpFile = dumpFile;
//Prepare the new dumpfile
pcap_dumper_t* newDumpFile = pcap_dump_open(pcapInstance, dumpFileStr);
//Do the switch before closing the old one, if it exists
dumpFile = newDumpFile;
//Close the old one, if this is not he first one.
if (oldDumpFile != NULL) {
 pcap_dump_close(oldDumpFile);
}

}

The thing is, is that i want to be able to run this method when that pcap
instance (each instance has its own thread) is running. 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 or do i need to implement my own?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20051120/5d54831a/attachment.html


More information about the Winpcap-users mailing list