Changeset 1f184fd for lib


Ignore:
Timestamp:
08/16/18 11:11:04 (2 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, master, ringdecrementfix, ringperformance
Children:
eeabc19b
Parents:
54a76f2
Message:

Don't keep creating and destroying ETSI decoders

This is expensive and is not something we want to be doing for
every packet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_etsilive.c

    r32ee9b2 r1f184fd  
    8383        etsithread_t *receivers;
    8484        int nextthreadid;
     85        wandder_etsispec_t *shareddec;
    8586} etsilive_format_data_t;
    8687
     
    227228        FORMAT_DATA->listenport = strdup(scan + 1);
    228229
     230        FORMAT_DATA->shareddec = wandder_create_etsili_decoder();
     231
    229232        return 0;
    230233}
     
    240243        if (FORMAT_DATA->listenport) {
    241244                free(FORMAT_DATA->listenport);
     245        }
     246        if (FORMAT_DATA->shareddec) {
     247                wandder_free_etsili_decoder(FORMAT_DATA->shareddec);
    242248        }
    243249        free(libtrace->format_data);
     
    589595
    590596        /* Should never get here because cache is set when packet is read */
    591         wandder_etsispec_t *dec;
    592597        size_t reclen;
     598        libtrace_t *libtrace = packet->trace;
     599
     600        assert(libtrace);
     601        assert(FORMAT_DATA->shareddec);
    593602
    594603        /* 0 should be ok here for quickly evaluating the first length
    595604         * field... */
    596         dec = wandder_create_etsili_decoder();
    597         wandder_attach_etsili_buffer(dec, packet->buffer, 0, false);
    598         reclen = (size_t)wandder_etsili_get_pdu_length(dec);
    599         wandder_free_etsili_decoder(dec);
     605        wandder_attach_etsili_buffer(FORMAT_DATA->shareddec, packet->buffer,
     606                        0, false);
     607        reclen = (size_t)wandder_etsili_get_pdu_length(
     608                        FORMAT_DATA->shareddec);
    600609
    601610        return reclen;
     
    611620         * this up again. */
    612621        struct timeval tv;
    613         wandder_etsispec_t *dec;
    614622
    615623        tv.tv_sec = 0;
    616624        tv.tv_usec = 0;
    617625
    618 
    619         dec = wandder_create_etsili_decoder();
    620         wandder_attach_etsili_buffer(dec, packet->buffer, 0, false);
    621         tv = wandder_etsili_get_header_timestamp(dec);
    622         wandder_free_etsili_decoder(dec);
     626        libtrace_t *libtrace = packet->trace;
     627
     628        assert(libtrace);
     629        assert(FORMAT_DATA->shareddec);
     630        wandder_attach_etsili_buffer(FORMAT_DATA->shareddec, packet->buffer,
     631                        0, false);
     632        tv = wandder_etsili_get_header_timestamp(FORMAT_DATA->shareddec);
    623633        return tv;
    624634}
Note: See TracChangeset for help on using the changeset viewer.