Ignore:
Timestamp:
05/20/14 03:25:13 (8 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
82facc5
Parents:
a5662447
Message:

Tidies up the pausing so that it now works as expected and a trace can easily be paused and restarted.
Ensures that packets will not be lost if pause is called on a file, any queued packets will be read (a message is sent allowing the user to drop these packets if they are unwanted).
Differentiates packets from other results in the queues to the reducer/reporter and makes a copy of the packets in result queues when pausing

  • this is needed to ensure that bad memory isn't referenced if a zero-copy trace is paused by closing sockets/associated data like in the case of ring:.

Fixed up the re-starting of traces which hadn't been finished to account for different configurations.
Adds a 'state' to libtrace to handle the state of parallel traces, rather than hacking around the existing 'started' boolean. Also provides two levels of checks for consistency if the trace is using existing that are checking started.

Various other bug fixes and tidy ups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/traceanon/traceanon_parallel.c

    r17a3dff rfac8c46  
    1313#include <data-struct/vector.h>
    1414#include <data-struct/message_queue.h>
     15#include <signal.h>
    1516
    1617bool enc_source = false;
     
    1819enum enc_type_t enc_type = ENC_NONE;
    1920char *key = NULL;
     21
     22
     23struct libtrace_t *trace = NULL;
     24
     25static void cleanup_signal(int signal)
     26{
     27        static int s = 0;
     28        (void)signal;
     29        // trace_interrupt();
     30        // trace_pstop isn't really signal safe because its got lots of locks in it
     31        // trace_pstop(trace);
     32        if (s == 0) {
     33                if (trace_ppause(trace) == -1)
     34                        trace_perror(trace, "Pause failed");
     35        }
     36        else {
     37                if (trace_pstart(trace, NULL, NULL, NULL) == -1)
     38                        trace_perror(trace, "Start failed");
     39        }
     40        s = !s;
     41}
     42
     43
    2044
    2145static void usage(char *argv0)
     
    166190                //libtrace_packet_t * packet_copy = trace_copy_packet(packet);
    167191                //libtrace_packet_t * packet_copy = trace_result_packet(trace, pkt);
    168                 trace_publish_result(trace, trace_packet_get_order(pkt), pkt);
     192                //trace_publish_result(trace, trace_packet_get_order(pkt), pkt);
     193                trace_publish_packet(trace, pkt);
    169194                //return ;
    170195        }
     
    181206int main(int argc, char *argv[])
    182207{
    183         struct libtrace_t *trace = 0;
     208        //struct libtrace_t *trace = 0;
    184209        struct libtrace_packet_t *packet/* = trace_create_packet()*/;
    185210        struct libtrace_out_t *writer = 0;
     211        struct sigaction sigact;
    186212        char *output = 0;
    187213        int level = -1;
     
    371397                return 1;
    372398        }
     399
     400        sigact.sa_handler = cleanup_signal;
     401        sigemptyset(&sigact.sa_mask);
     402        sigact.sa_flags = SA_RESTART;
     403
     404        sigaction(SIGINT, &sigact, NULL);
     405        sigaction(SIGTERM, &sigact, NULL);
    373406       
    374407        // Read in the resulting packets and then free them when done
Note: See TracChangeset for help on using the changeset viewer.