void *ExporterSink::exporterSinkProcess(void *arg) { ExporterSink *sink = (ExporterSink *)arg; ConcurrentQueue<Packet*> *queue = sink->getQueue(); Packet *p; bool result; // our deadline struct timeval deadline; int pckCount; msg(MSG_INFO, "Sink: now running ExporterSink thread"); while(!sink->exitFlag) { sink->startNewPacketStream(); // let's get the first packet gettimeofday(&deadline, 0); result = queue->pop(&p); if(result == true) { // we got a packet, so let's add the record result = sink->addPacket(p); } pckCount = 1; // now calculate the deadline by which the packet has to leave the exporter gettimeofday(&deadline, 0); deadline.tv_usec += sink->exportTimeout * 1000L; if(deadline.tv_usec > 1000000L) { deadline.tv_sec += (deadline.tv_usec / 1000000L); deadline.tv_usec %= 1000000L; } while(!sink->exitFlag && (pckCount < sink->ipfix_maxrecords)) { // Try to get next packet from queue before our deadline result = queue->popAbs(deadline, &p); // check for timeout and break loop if neccessary if (!result) break; // no timeout received, continue waiting, but // count only if packet was added if(sink->addPacket(p) == true) pckCount++; } sink->flushPacketStream(); } return 0; }