Changeset 16840ea
- Timestamp:
- 02/19/15 17:01:12 (6 years ago)
- 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:
- e8c0a9c
- Parents:
- 92020b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_dag25.c
r92020b8 r16840ea 108 108 /* "Global" data that is stored for each DAG output trace */ 109 109 struct dag_format_data_out_t { 110 /* String containing the DAG device name */111 char *device_name;112 110 /* The DAG device being used for writing */ 113 111 struct dag_dev_t *device; … … 160 158 /* DAG device */ 161 159 struct dag_dev_t *device; 162 /* String containing the DAG device name */163 char *device_name;164 160 /* Boolean flag indicating whether the trace is currently attached */ 165 161 int stream_attached; … … 228 224 FORMAT_DATA_OUT->stream_attached = 0; 229 225 FORMAT_DATA_OUT->device = NULL; 230 FORMAT_DATA_OUT->device_name = NULL;231 226 FORMAT_DATA_OUT->dagstream = 0; 232 227 FORMAT_DATA_OUT->waiting = 0; … … 254 249 memset(&stream_data, 0, sizeof(stream_data)); 255 250 libtrace_list_push_back(FORMAT_DATA->per_stream, &stream_data); 256 FORMAT_DATA->device_name = NULL;257 251 } 258 252 … … 419 413 static int dag_init_output(libtrace_out_t *libtrace) 420 414 { 415 /* Upon successful creation, the device name is stored against the 416 * device and free when it is free()d */ 417 char *dag_dev_name = NULL; 421 418 char *scan = NULL; 422 419 struct dag_dev_t *dag_device = NULL; … … 441 438 * If no stream is specified, we will write using stream 1 */ 442 439 if ((scan = strchr(libtrace->uridata,',')) == NULL) { 443 FORMAT_DATA_OUT->device_name = strdup(libtrace->uridata);440 dag_dev_name = strdup(libtrace->uridata); 444 441 } else { 445 FORMAT_DATA_OUT->device_name = 446 (char *)strndup(libtrace->uridata, 442 dag_dev_name = (char *)strndup(libtrace->uridata, 447 443 (size_t)(scan - libtrace->uridata)); 448 444 stream = atoi(++scan); … … 451 447 452 448 /* See if our DAG device is already open */ 453 dag_device = dag_find_open_device( FORMAT_DATA_OUT->device_name);449 dag_device = dag_find_open_device(dag_dev_name); 454 450 455 451 if (dag_device == NULL) { 456 452 /* Device not yet opened - open it ourselves */ 457 dag_device = dag_open_output_device(libtrace, 458 FORMAT_DATA_OUT->device_name); 453 dag_device = dag_open_output_device(libtrace, dag_dev_name); 454 } else { 455 /* Otherwise, just use the existing one */ 456 free(dag_dev_name); 457 dag_dev_name = NULL; 459 458 } 460 459 461 460 /* Make sure we have successfully opened a DAG device */ 462 461 if (dag_device == NULL) { 463 if (FORMAT_DATA_OUT->device_name) { 464 free(FORMAT_DATA_OUT->device_name); 465 FORMAT_DATA_OUT->device_name = NULL; 462 if (dag_dev_name) { 463 free(dag_dev_name); 466 464 } 467 465 pthread_mutex_unlock(&open_dag_mutex); … … 476 474 /* Creates and initialises a DAG input trace */ 477 475 static int dag_init_input(libtrace_t *libtrace) { 476 /* Upon successful creation, the device name is stored against the 477 * device and free when it is free()d */ 478 char *dag_dev_name = NULL; 478 479 char *scan = NULL; 479 480 int stream = 0; … … 494 495 */ 495 496 if ((scan = strchr(libtrace->uridata,',')) == NULL) { 496 FORMAT_DATA->device_name = strdup(libtrace->uridata);497 dag_dev_name = strdup(libtrace->uridata); 497 498 } else { 498 FORMAT_DATA->device_name = (char *)strndup(libtrace->uridata,499 dag_dev_name = (char *)strndup(libtrace->uridata, 499 500 (size_t)(scan - libtrace->uridata)); 500 501 stream = atoi(++scan); … … 504 505 505 506 /* See if our DAG device is already open */ 506 dag_device = dag_find_open_device( FORMAT_DATA->device_name);507 dag_device = dag_find_open_device(dag_dev_name); 507 508 508 509 if (dag_device == NULL) { 509 510 /* Device not yet opened - open it ourselves */ 510 dag_device=dag_open_device(libtrace, FORMAT_DATA->device_name); 511 dag_device = dag_open_device(libtrace, dag_dev_name); 512 } else { 513 /* Otherwise, just use the existing one */ 514 free(dag_dev_name); 515 dag_dev_name = NULL; 511 516 } 512 517 513 518 /* Make sure we have successfully opened a DAG device */ 514 519 if (dag_device == NULL) { 515 if ( FORMAT_DATA->device_name)516 free( FORMAT_DATA->device_name);517 FORMAT_DATA->device_name = NULL;520 if (dag_dev_name) 521 free(dag_dev_name); 522 dag_dev_name = NULL; 518 523 pthread_mutex_unlock(&open_dag_mutex); 519 524 return -1; … … 806 811 /* Clear the list */ 807 812 libtrace_list_deinit(FORMAT_DATA->per_stream); 808 809 if (FORMAT_DATA->device_name)810 free(FORMAT_DATA->device_name);811 813 free(libtrace->format_data); 812 814 pthread_mutex_unlock(&open_dag_mutex); … … 844 846 if (FORMAT_DATA_OUT->device->ref_count == 0) 845 847 dag_close_device(FORMAT_DATA_OUT->device); 846 if (FORMAT_DATA_OUT->device_name)847 free(FORMAT_DATA_OUT->device_name);848 848 free(libtrace->format_data); 849 849 pthread_mutex_unlock(&open_dag_mutex);
Note: See TracChangeset
for help on using the changeset viewer.