Ignore:
Timestamp:
09/17/14 13:45:29 (7 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:
9e429e8
Parents:
2498008
Message:

Remove anything to do with the combiner from set configuration and removes any options/storage related to these such as the next expected packet.

Instead this is done using trace_set_combiner now, and the for the built-in combiners.h header. This is a lot more flexible and allows the users to specify there own combiner, and any number of options for it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace_parallel.c

    r2498008 rd994324  
    339339}
    340340
    341 /** Used below in trace_make_results_packets_safe */
    342 static void do_copy_result_packet(void *data)
    343 {
    344         libtrace_result_t *res = (libtrace_result_t *)data;
     341/** Makes a packet safe, a packet may become invaild after a
     342 * pause (or stop/destroy) of a trace. This copies a packet
     343 * in such a way that it will be able to survive a pause.
     344 *
     345 * However this will not allow the packet to be used after
     346 * the format is destroyed. Or while the trace is still paused.
     347 */
     348DLLEXPORT void libtrace_make_packet_safe(libtrace_packet_t *pkt) {
     349        // Duplicate the packet in standard malloc'd memory and free the
     350        // original, This is a 1:1 exchange so is ocache count remains unchanged.
     351        if (pkt->buf_control != TRACE_CTRL_PACKET) {
     352                libtrace_packet_t *dup;
     353                dup = trace_copy_packet(pkt);
     354                /* Release the external buffer */
     355                trace_fin_packet(pkt);
     356                /* Copy the duplicated packet over the existing */
     357                memcpy(pkt, dup, sizeof(libtrace_packet_t));
     358        }
     359}
     360
     361/**
     362 * Makes a libtrace_result_t safe, used when pausing a trace.
     363 * This will call libtrace_make_packet_safe if the result is
     364 * a packet.
     365 */
     366DLLEXPORT void libtrace_make_result_safe(libtrace_result_t *res) {
    345367        if (res->type == RESULT_PACKET) {
    346                 // Duplicate the packet in standard malloc'd memory and free the
    347                 // original, This is a 1:1 exchange so is ocache count remains unchanged.
    348                 libtrace_packet_t *oldpkt, *dup;
    349                 oldpkt = (libtrace_packet_t *) res->value;
    350                 dup = trace_copy_packet(oldpkt);
    351                 res->value = (void *)dup;
    352                 trace_destroy_packet(oldpkt);
     368                libtrace_make_packet_safe(res->value.pkt);
    353369        }
    354370}
     
    19982014        return result->key;
    19992015}
    2000 DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, void * value) {
     2016DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_types_t value) {
    20012017        result->value = value;
    20022018}
    2003 DLLEXPORT void* libtrace_result_get_value(libtrace_result_t * result) {
     2019DLLEXPORT libtrace_generic_types_t libtrace_result_get_value(libtrace_result_t * result) {
    20042020        return result->value;
    20052021}
    2006 DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, void * value) {
     2022DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_types_t value) {
    20072023        result->key = key;
    20082024        result->value = value;
     
    20522068 * Should only be called by a perpkt thread, i.e. from a perpkt handler
    20532069 */
    2054 DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, void * value, int type) {
     2070DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_types_t value, int type) {
    20552071        libtrace_result_t res;
    20562072        res.type = type;
     
    20602076        libtrace->combiner.publish(libtrace, t->perpkt_num, &libtrace->combiner, &res);
    20612077        return;
     2078}
     2079
     2080/**
     2081 * Sets a combiner function against the trace.
     2082 */
     2083DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_types_t config){
     2084        if (combiner) {
     2085                trace->combiner = *combiner;
     2086                trace->combiner.configuration = config;
     2087        } else {
     2088                // No combiner, so don't try use it
     2089                memset(&trace->combiner, 0, sizeof(trace->combiner));
     2090        }
    20622091}
    20632092
     
    20942123                case TRACE_OPTION_SET_PERPKT_THREAD_COUNT:
    20952124                        libtrace->config.perpkt_threads = *((int *) value);
    2096                         return 1;
    2097                 case TRACE_DROP_OUT_OF_ORDER:
    2098                         if (*((int *) value))
    2099                                 libtrace->reporter_flags |= REDUCE_DROP_OOO;
    2100                         else
    2101                                 libtrace->reporter_flags &= ~REDUCE_DROP_OOO;
    2102                         return 1;
    2103                 case TRACE_OPTION_SEQUENTIAL:
    2104                         libtrace->combiner = combiner_ordered;
    2105                         if (*((int *) value))
    2106                                 libtrace->reporter_flags |= REDUCE_SEQUENTIAL;
    2107                         else
    2108                                 libtrace->reporter_flags &= ~REDUCE_SEQUENTIAL;
    2109                         return 1;
    2110                 case TRACE_OPTION_ORDERED:
    2111                         libtrace->combiner = combiner_ordered;
    2112                         if (*((int *) value))
    2113                                 libtrace->reporter_flags |= REDUCE_ORDERED;
    2114                         else
    2115                                 libtrace->reporter_flags &= ~REDUCE_ORDERED;
    21162125                        return 1;
    21172126                case TRACE_OPTION_TRACETIME:
Note: See TracChangeset for help on using the changeset viewer.