Changeset f625817 for lib/trace.c


Ignore:
Timestamp:
09/11/15 15:00:27 (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:
322c516
Parents:
8c7490fe
Message:

Reworked callback API and removed old per_msg and reporter functions

Updated tracertstats to use the new callback API.

Extended the callback approach to the reporter thread as well as the per
packet threads.

Added libtrace_callback_set_t structure, which is used to register the
user callback functions.

Added callback functionality for MESSAGE_RESULT (needed now that reporter
threads also do callbacks) and MESSAGE_USER (for user-defined messages). The
MESSAGE_USER callback is essentially the same as the old per_msg function
style.

Updated combiners to use send_message to pass results to the reporter thread.
send_message itself is now no longer static, so that combiners can use it.

Disabled building of tracestats_parallel as it was using the older version
of the callback API. Will update in a future commit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r0a368ae rf625817  
    269269        libtrace->perpkt_queue_full = false;
    270270        libtrace->global_blob = NULL;
    271         libtrace->per_msg = NULL;
    272         libtrace->reporter = NULL;
    273271        libtrace->hasher = NULL;
    274272        libtrace_zero_ocache(&libtrace->packet_freelist);
     
    288286        ZERO_USER_CONFIG(libtrace->config);
    289287        memset(&libtrace->combiner, 0, sizeof(libtrace->combiner));
    290         memset(&libtrace->callbacks, 0, sizeof(libtrace->callbacks));
     288        libtrace->perpkt_cbs = NULL;
     289        libtrace->reporter_cbs = NULL;
    291290
    292291        /* Parse the URI to determine what sort of trace we are dealing with */
     
    393392        libtrace->perpkt_queue_full = false;
    394393        libtrace->global_blob = NULL;
    395         libtrace->per_msg = NULL;
    396         libtrace->reporter = NULL;
    397394        libtrace->hasher = NULL;
    398395        libtrace_zero_ocache(&libtrace->packet_freelist);
     
    409406        ZERO_USER_CONFIG(libtrace->config);
    410407        memset(&libtrace->combiner, 0, sizeof(libtrace->combiner));
    411         memset(&libtrace->callbacks, 0, sizeof(libtrace->callbacks));
     408        libtrace->perpkt_cbs = NULL;
     409        libtrace->reporter_cbs = NULL;
    412410       
    413411        for(tmp=formats_list;tmp;tmp=tmp->next) {
     
    721719                // This has all of our packets
    722720                libtrace_ocache_destroy(&libtrace->packet_freelist);
    723                 if (libtrace->combiner.destroy && libtrace->reporter)
     721                if (libtrace->combiner.destroy && libtrace->reporter_cbs)
    724722                        libtrace->combiner.destroy(libtrace, &libtrace->combiner);
    725723                free(libtrace->perpkt_threads);
    726724                libtrace->perpkt_threads = NULL;
    727725                libtrace->perpkt_thread_count = 0;
    728         }
     726
     727        }
     728
     729        if (libtrace->perpkt_cbs)
     730                trace_destroy_callback_set(libtrace->perpkt_cbs);
     731        if (libtrace->reporter_cbs)
     732                trace_destroy_callback_set(libtrace->reporter_cbs);
     733
    729734       
    730735        if (libtrace->event.packet) {
Note: See TracChangeset for help on using the changeset viewer.