You should call pfring_breakloop from the other thread, and pfring_close from the capture thread
Alfredo > On 26 Nov 2014, at 01:44, Behrooz Shafiee <[email protected]> wrote: > > Ok, I guess I should have used pfring_breakloop before pfring_close to break > recv loop. > > On Tue, Nov 25, 2014 at 7:35 PM, Behrooz Shafiee <[email protected] > <mailto:[email protected]>> wrote: > Hello Everyone, > > I have a reader thread which reads input packets using pfring_recv function. > On the other hand, at some point somebody might want to exist the program > from another thread (main thread) and calls pfring_close which causes > internal error in pfring_rcev functions. I think pfring is not thread safe, > right? so what the proper way of terminating application in my scenario? > here is my rcvLoop thread: > > while(isRunning){ > //Get a packet > int res = pfring_recv((pfring*)pd,&_packet,0,&_header,1); > .... > } > > > and here is a how pfring_recv fails when pfring_close is called from another > thread: > > Program terminated with signal SIGSEGV, Segmentation fault. > #0 0x00007f79a86ea2bc in pfring_read_ixia_hw_timestamp () from > /usr/local/lib/libpfring.so > (gdb) bt > #0 0x00007f79a86ea2bc in pfring_read_ixia_hw_timestamp () from > /usr/local/lib/libpfring.so > #1 0x00007f79a86ea348 in pfring_handle_ixia_hw_timestamp () from > /usr/local/lib/libpfring.so > #2 0x00007f79a86e5115 in pfring_recv () from /usr/local/lib/libpfring.so > #3 0x0000000000439920 in FUSESwift::BFSNetwork::rcvLoop () at > src/BFSNetwork.cpp:479 > #4 0x0000000000436f59 in std::_Bind_simple<void > (*())()>::_M_invoke<>(std::_Index_tuple<>) (this=0x2237e88) at > /usr/include/c++/4.9/functional:1700 > #5 0x0000000000436bbf in std::_Bind_simple<void (*())()>::operator()() > (this=0x2237e88) at /usr/include/c++/4.9/functional:1688 > #6 0x0000000000436564 in std::thread::_Impl<std::_Bind_simple<void (*())()> > >::_M_run() (this=0x2237e70) at /usr/include/c++/4.9/thread:115 > #7 0x00007f79a826f4a0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 > #8 0x00007f79a8b80182 in start_thread () from > /lib/x86_64-linux-gnu/libpthread.so.0 > #9 0x00007f79a79cafbd in clone () from /lib/x86_64-linux-gnu/libc.so.6 > > Thanks, > > -- > Behrooz > > > > -- > Behrooz > _______________________________________________ > Ntop-misc mailing list > [email protected] <mailto:[email protected]> > http://listgateway.unipi.it/mailman/listinfo/ntop-misc > <http://listgateway.unipi.it/mailman/listinfo/ntop-misc>
_______________________________________________ Ntop-misc mailing list [email protected] http://listgateway.unipi.it/mailman/listinfo/ntop-misc
