Ignore:
Timestamp:
08/21/15 11:22:30 (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:
eea427f
Parents:
76291d1
Message:

Updates the new interface to be more complete

This should work around any issues with systems without thread support.
This still remains compatible with existing code.
Examples/tools/tests still need to be updated to make use of the new interface.
And tests also need to be updated.
Adds debug memory stats as an option to configure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracestats/tracestats_parallel.c

    r76291d1 r4007dbb  
    145145
    146146
    147 static void* fn_starting(libtrace_t *trace UNUSED, libtrace_thread_t *t,
    148                      libtrace_generic_t data UNUSED, void *global UNUSED, void*tls UNUSED) {
     147static void* fn_starting(libtrace_t *trace UNUSED, libtrace_thread_t *t UNUSED, void *global UNUSED) {
    149148        /* Allocate space to hold a total count and one for each filter */
    150         statistics_t *results = calloc(1, sizeof(statistics_t) * (filter_count + 1));
    151         trace_set_tls(t, results);
    152         return NULL;
    153 }
    154 
    155 
    156 static void* fn_stopping(libtrace_t *trace, libtrace_thread_t *t UNUSED,
    157                      libtrace_generic_t data UNUSED, void *global UNUSED, void*tls) {
     149        return calloc(1, sizeof(statistics_t) * (filter_count + 1));
     150}
     151
     152
     153static void fn_stopping(libtrace_t *trace, libtrace_thread_t *t UNUSED,
     154                        void *global UNUSED, void*tls) {
    158155        statistics_t *results = tls;
    159156        libtrace_generic_t gen;
     
    162159        gen.ptr = results;
    163160        trace_publish_result(trace, t, 0, gen, RESULT_USER);
    164         return NULL;
    165 }
    166 
    167 static void* fn_packet(libtrace_t *trace, libtrace_thread_t *t UNUSED,
    168                    libtrace_generic_t data, void *global UNUSED, void*tls) {
     161}
     162
     163static libtrace_packet_t* fn_packet(libtrace_t *trace, libtrace_thread_t *t UNUSED,
     164                   void *global UNUSED, void*tls, libtrace_packet_t *pkt) {
    169165        statistics_t *results = tls;
    170166        int i, wlen;
    171167
    172168        /* Apply filters to every packet note the result */
    173         wlen = trace_get_wire_length(data.pkt);
     169        wlen = trace_get_wire_length(pkt);
    174170        for(i=0;i<filter_count;++i) {
    175171                if (filters[i].filter == NULL)
    176172                        continue;
    177                 if(trace_apply_filter(filters[i].filter,data.pkt) > 0) {
     173                if(trace_apply_filter(filters[i].filter,pkt) > 0) {
    178174                        results[i+1].count++;
    179175                        results[i+1].bytes+=wlen;
     
    188184        results[0].count++;
    189185        results[0].bytes +=wlen;
    190         return data.pkt;
     186        return pkt;
    191187}
    192188
     
    220216        }
    221217
    222         trace_set_handler(trace, MESSAGE_PACKET, fn_packet);
    223         trace_set_handler(trace, MESSAGE_STARTING, fn_starting);
    224         trace_set_handler(trace, MESSAGE_STOPPING, fn_stopping);
     218        trace_cb_packet(trace, fn_packet);
     219        trace_cb_starting(trace, fn_starting);
     220        trace_cb_stopping(trace, fn_stopping);
    225221
    226222        /* Start the trace as a parallel trace */
Note: See TracChangeset for help on using the changeset viewer.