Changeset fac8c46 for tools


Ignore:
Timestamp:
05/20/14 03:25:13 (6 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.

Location:
tools
Files:
2 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
  • tools/tracestats/tracestats_parallel.c

    r5ce14a5 rfac8c46  
    5959#include <pthread.h>
    6060
    61 struct libtrace_t *trace;
     61struct libtrace_t *trace = NULL;
    6262
    6363static void cleanup_signal(int signal)
    6464{
     65        static int s = 0;
    6566        (void)signal;
    66         //trace_interrupt();
     67        // trace_interrupt();
    6768        // trace_pstop isn't really signal safe because its got lots of locks in it
    68         trace_pstop(trace);
     69        // trace_pstop(trace);
     70        if (s == 0) {
     71                if (trace_ppause(trace) == -1)
     72                        trace_perror(trace, "Pause failed");
     73        }
     74        else {
     75                if (trace_pstart(trace, NULL, NULL, NULL) == -1)
     76                        trace_perror(trace, "Start failed");
     77        }
     78        s = !s;
    6979}
    7080
     
    121131                        case MESSAGE_STOPPED:
    122132                                trace_publish_result(trace, 0, results); // Only ever using a single key 0
    123                                 fprintf(stderr, "Thread published resuslts WOWW \n");
     133                                fprintf(stderr, "Thread published resuslts WOWW\n");
    124134                                break;
    125135                        case MESSAGE_STARTED:
    126136                                results = calloc(1, sizeof(statistics_t) * (filter_count + 1));
    127137                                break;
    128                         case MESSAGE_PAUSE:
     138                        case MESSAGE_DO_PAUSE:
    129139                                fprintf(stderr, "GOT Asked to pause ahh\n");
     140                                break;
     141                        case MESSAGE_PAUSING:
     142                                fprintf(stderr, "Thread is pausing\n");
     143                                break;
     144                        case MESSAGE_PAUSED:
     145                                fprintf(stderr, "Thread has paused\n");
    130146                                break;
    131147                }
     
    189205}
    190206
    191 static uint64_t rand_hash(libtrace_packet_t * pkt) {
     207static uint64_t rand_hash(libtrace_packet_t * pkt, void *data) {
    192208        return rand();
    193209}
    194210
    195 static uint64_t bad_hash(libtrace_packet_t * pkt) {
     211static uint64_t bad_hash(libtrace_packet_t * pkt, void *data) {
    196212        return 0;
    197213}
     
    212228        int option = 2;
    213229        //option = 10000;
    214         //trace_parallel_config(trace, TRACE_OPTION_USE_DEDICATED_HASHER, &option);
     230        trace_parallel_config(trace, TRACE_OPTION_USE_DEDICATED_HASHER, &option);
     231        trace_set_hasher(trace, HASHER_CUSTOM, &rand_hash, NULL);
    215232        //trace_parallel_config(trace, TRACE_OPTION_USE_SLIDING_WINDOW_BUFFER, &option);
    216233        option = 2;
Note: See TracChangeset for help on using the changeset viewer.