From bernhard at ICSI.Berkeley.EDU Tue May 13 13:47:07 2014 From: bernhard at ICSI.Berkeley.EDU (Bernhard Amann) Date: Tue, 13 May 2014 13:47:07 -0700 Subject: [TM] [git] branch 'topic/bernhard/exit-after-trace' created Message-ID: <201405132047.s4DKl7DE023067@bro-ids.icir.org> Repository : ssh://git at bro-ids.icir.org/time-machine New branch : topic/bernhard/exit-after-trace Referencing: 4509a9a8451b1185a06c4b05b921d5c4f83779e1 From bernhard at ICSI.Berkeley.EDU Tue May 13 13:47:09 2014 From: bernhard at ICSI.Berkeley.EDU (Bernhard Amann) Date: Tue, 13 May 2014 13:47:09 -0700 Subject: [TM] [git] topic/bernhard/exit-after-trace: Exit by default after finishing reading a tracefile. (4509a9a) Message-ID: <201405132047.s4DKl9Gv023078@bro-ids.icir.org> Repository : ssh://git at bro-ids.icir.org/time-machine On branch : topic/bernhard/exit-after-trace >--------------------------------------------------------------- commit 4509a9a8451b1185a06c4b05b921d5c4f83779e1 Author: Bernhard Amann Date: Tue May 13 13:28:44 2014 -0700 Exit by default after finishing reading a tracefile. Just syncs the memory- and file-buffers to disk and exits. Note that this patch is a tad dirty and just exposes some methods it needs publically. >--------------------------------------------------------------- 4509a9a8451b1185a06c4b05b921d5c4f83779e1 src/Fifo.cc | 7 +++++++ src/Fifo.hh | 3 ++- src/Storage.cc | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Fifo.cc b/src/Fifo.cc index 39e7174..ef0e58e 100644 --- a/src/Fifo.cc +++ b/src/Fifo.cc @@ -87,6 +87,13 @@ bool Fifo::matchPkt(const struct pcap_pkthdr* header, } +void Fifo::EvictAll() { + while (fm->getHeldPkts()>0) { + fd->addPkt(fm->getS()); + fm->popPkt(); + } +} + uint64_t Fifo::pktEviction() { uint64_t n=0; uint64_t i; diff --git a/src/Fifo.hh b/src/Fifo.hh index 8d06153..5a1f010 100644 --- a/src/Fifo.hh +++ b/src/Fifo.hh @@ -41,6 +41,7 @@ public: void start(); virtual ~Fifo(); uint64_t pktEviction(); + void EvictAll(); bool addPkt(const struct pcap_pkthdr* header, const unsigned char* packet, Connection*); const FifoMem* getFm(); @@ -112,6 +113,7 @@ public: std::string getStatsStr(); static std::string getStatsStrHeader(); uint64_t query(QueryRequest*, QueryResult*, IntervalSet*); + FifoDisk* fd; protected: bool do_cutoff; uint64_t cutoff; @@ -135,7 +137,6 @@ protected: uint64_t cutoff_pkts; FifoMem* fm; - FifoDisk* fd; // pthread_t m2d_thread_id; // volatile int m2d_thread_stop; // int i; diff --git a/src/Storage.cc b/src/Storage.cc index 92d5f68..1406fef 100644 --- a/src/Storage.cc +++ b/src/Storage.cc @@ -53,6 +53,13 @@ void *capture_thread(void *arg) { // sleep(15); pcap_loop(storage->ph, -1, (pcap_handler)callback, (u_char*)storage); tmlog(TM_LOG_NOTE, "storage", "pcap input exhausted"); + for (std::list::iterator i=storage->fifos.begin(); i!=storage->fifos.end(); i++) { + (*i)->EvictAll(); + for (std::list::iterator j=(*i)->fd->filesBeginIt(); j!=(*i)->fd->filesEndIt(); j++) { + (*j)->flush(); + } + } + exit(0); return NULL; }