Changeset 3440627


Ignore:
Timestamp:
02/04/15 14:22:40 (6 years ago)
Author:
Shane Alcock <salcock@…>
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:
c5ac872
Parents:
3fc3267 (diff), 4bd6393 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'dagdevicename' into develop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag25.c

    r68d3308 r4bd6393  
    104104/* "Global" data that is stored for each DAG output trace */
    105105struct dag_format_data_out_t {
     106        /* String containing the DAG device name */
     107        char *device_name;
    106108        /* The DAG device being used for writing */
    107109        struct dag_dev_t *device;
     
    132134        } duck;
    133135
    134         /* The DAG device that we are reading from */
     136        /* String containing the DAG device name */
     137        char *device_name;
     138        /* The DAG device that we are reading from */
    135139        struct dag_dev_t *device;
    136140        /* The DAG stream that we are reading from */
     
    208212        FORMAT_DATA_OUT->stream_attached = 0;
    209213        FORMAT_DATA_OUT->device = NULL;
     214        FORMAT_DATA_OUT->device_name = NULL;
    210215        FORMAT_DATA_OUT->dagstream = 0;
    211216        FORMAT_DATA_OUT->waiting = 0;
     
    223228        FORMAT_DATA->stream_attached = 0;
    224229        FORMAT_DATA->drops = 0;
     230        FORMAT_DATA->device_name = NULL;
    225231        FORMAT_DATA->device = NULL;
    226232        FORMAT_DATA->dagstream = 0;
     
    392398/* Creates and initialises a DAG output trace */
    393399static int dag_init_output(libtrace_out_t *libtrace) {
    394         char *dag_dev_name = NULL;
    395400        char *scan = NULL;
    396401        struct dag_dev_t *dag_device = NULL;
     
    415420         * If no stream is specified, we will write using stream 1 */
    416421        if ((scan = strchr(libtrace->uridata,',')) == NULL) {
    417                 dag_dev_name = strdup(libtrace->uridata);
     422                FORMAT_DATA_OUT->device_name = strdup(libtrace->uridata);
    418423        } else {
    419                 dag_dev_name = (char *)strndup(libtrace->uridata,
     424                FORMAT_DATA_OUT->device_name =
     425                                (char *)strndup(libtrace->uridata,
    420426                                (size_t)(scan - libtrace->uridata));
    421427                stream = atoi(++scan);
     
    424430
    425431        /* See if our DAG device is already open */
    426         dag_device = dag_find_open_device(dag_dev_name);
     432        dag_device = dag_find_open_device(FORMAT_DATA_OUT->device_name);
    427433
    428434        if (dag_device == NULL) {
    429435                /* Device not yet opened - open it ourselves */
    430                 dag_device = dag_open_output_device(libtrace, dag_dev_name);
    431         } else {
    432                 /* Otherwise, just use the existing one */
    433                 free(dag_dev_name);
    434                 dag_dev_name = NULL;
     436                dag_device = dag_open_output_device(libtrace,
     437                                FORMAT_DATA_OUT->device_name);
    435438        }
    436439
    437440        /* Make sure we have successfully opened a DAG device */
    438441        if (dag_device == NULL) {
    439                 if (dag_dev_name) {
    440                         free(dag_dev_name);
     442                if (FORMAT_DATA_OUT->device_name) {
     443                        free(FORMAT_DATA_OUT->device_name);
     444                        FORMAT_DATA_OUT->device_name = NULL;
    441445                }
    442446                pthread_mutex_unlock(&open_dag_mutex);
     
    451455/* Creates and initialises a DAG input trace */
    452456static int dag_init_input(libtrace_t *libtrace) {
    453         char *dag_dev_name = NULL;
    454457        char *scan = NULL;
    455458        int stream = 0;
     
    467470         * If no stream is specified, we will read from stream 0 */
    468471        if ((scan = strchr(libtrace->uridata,',')) == NULL) {
    469                 dag_dev_name = strdup(libtrace->uridata);
     472                FORMAT_DATA->device_name = strdup(libtrace->uridata);
    470473        } else {
    471                 dag_dev_name = (char *)strndup(libtrace->uridata,
     474                FORMAT_DATA->device_name = (char *)strndup(libtrace->uridata,
    472475                                (size_t)(scan - libtrace->uridata));
    473476                stream = atoi(++scan);
     
    477480
    478481        /* See if our DAG device is already open */
    479         dag_device = dag_find_open_device(dag_dev_name);
     482        dag_device = dag_find_open_device(FORMAT_DATA->device_name);
    480483
    481484        if (dag_device == NULL) {
    482485                /* Device not yet opened - open it ourselves */
    483                 dag_device = dag_open_device(libtrace, dag_dev_name);
    484         } else {
    485                 /* Otherwise, just use the existing one */
    486                 free(dag_dev_name);
    487                 dag_dev_name = NULL;
     486                dag_device=dag_open_device(libtrace, FORMAT_DATA->device_name);
    488487        }
    489488
    490489        /* Make sure we have successfully opened a DAG device */
    491490        if (dag_device == NULL) {
    492                 if (dag_dev_name)
    493                         free(dag_dev_name);
    494                 dag_dev_name = NULL;
     491                if (FORMAT_DATA->device_name)
     492                        free(FORMAT_DATA->device_name);
     493                FORMAT_DATA->device_name = NULL;
    495494                pthread_mutex_unlock(&open_dag_mutex);
    496495                return -1;
     
    682681        if (DUCK.dummy_duck)
    683682                trace_destroy_dead(DUCK.dummy_duck);
     683        if (FORMAT_DATA->device_name)
     684                free(FORMAT_DATA->device_name);
    684685        free(libtrace->format_data);
    685686        pthread_mutex_unlock(&open_dag_mutex);
     
    715716        if (FORMAT_DATA_OUT->device->ref_count == 0)
    716717                dag_close_device(FORMAT_DATA_OUT->device);
     718        if (FORMAT_DATA_OUT->device_name)
     719                free(FORMAT_DATA_OUT->device_name);
    717720        free(libtrace->format_data);
    718721        pthread_mutex_unlock(&open_dag_mutex);
Note: See TracChangeset for help on using the changeset viewer.