Changeset 62b2d97


Ignore:
Timestamp:
01/08/19 09:40:10 (21 months ago)
Author:
Jacob Van Walraven <jcv9@…>
Branches:
develop
Children:
3c828b8
Parents:
f47025d
Message:

Add callback for meta packets

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace_int.h

    r37ee856 r62b2d97  
    294294        fn_cb_dataless message_pausing;
    295295        fn_cb_packet message_packet;
     296        fn_cb_packet message_meta_packet;
    296297        fn_cb_result message_result;
    297298        fn_cb_first_packet message_first_packet;
  • lib/libtrace_parallel.h

    rc22a4bb r62b2d97  
    135135         */
    136136        MESSAGE_PACKET,
     137
     138        /** A libtrace meta packet is ready, this will trigger the meta packet
     139         *  callback for the processing threads.
     140         */
     141        MESSAGE_META_PACKET,
    137142
    138143        /** A libtrace result is ready, this will trigger the result callback
     
    519524
    520525/**
     526 * A callback function triggered when a processing thread receives a meta packet.
     527 *
     528 * @param libtrace The parallel trace.
     529 * @param t The thread that is running
     530 * @param global The global storage.
     531 * @param tls The thread local storage.
     532 * @param packet The packet to be processed.
     533 *
     534 * @return either the packet itself if it is not being published as a result
     535 *   or NULL otherwise. If returning NULL, it is the user's responsibility
     536 *   to ensure the packet is freed when the reporter thread is finished with it.
     537 */
     538typedef libtrace_packet_t* (*fn_cb_meta_packet)(libtrace_t *libtrace,
     539                                           libtrace_thread_t *t,
     540                                           void *global,
     541                                           void *tls,
     542                                           libtrace_packet_t *packet);
     543
     544/**
    521545 * Callback for handling a result message. Should only be required by the
    522546 * reporter thread.
     
    599623DLLEXPORT int trace_set_packet_cb(libtrace_callback_set_t *cbset,
    600624                fn_cb_packet handler);
     625
     626/**
     627 * Registers a meta packet callback against a callback set.
     628 *
     629 * @param cbset The callback set.
     630 * @param handler The meta packet callback funtion.
     631 * @return 0 if successful, -1 otherwise.
     632 */
     633DLLEXPORT int trace_set_meta_packet_cb(libtrace_callback_set_t *cbset,
     634                fn_cb_meta_packet handler);
    601635
    602636/**
  • lib/trace_parallel.c

    r9c46b65 r62b2d97  
    242242        case MESSAGE_PACKET:
    243243                return;
    244         }
    245 
     244        case MESSAGE_META_PACKET:
     245                return;
     246        }
    246247        if (fn)
    247248                (*fn)(trace, thread, trace->global_blob, thread->user_data);
     
    496497                        t->accepted_packets++;
    497498                }
    498                 if (trace->perpkt_cbs->message_packet)
    499                         *packet = (*trace->perpkt_cbs->message_packet)(trace, t, trace->global_blob, t->user_data, *packet);
     499
     500                /* If packet is meta call the meta callback */
     501                if (IS_LIBTRACE_META_PACKET((*packet))) {
     502                        if (trace->perpkt_cbs->message_meta_packet) {
     503                                *packet = (*trace->perpkt_cbs->message_meta_packet)(trace, t, trace->global_blob,
     504                                        t->user_data, *packet);
     505                        }
     506                } else {
     507                        if (trace->perpkt_cbs->message_packet) {
     508                                *packet = (*trace->perpkt_cbs->message_packet)(trace, t, trace->global_blob, t->user_data,
     509                                        *packet);
     510                        }
     511                }
    500512                trace_fin_packet(*packet);
    501513        } else {
     
    20352047                fn_cb_packet handler) {
    20362048        cbset->message_packet = handler;
     2049        return 0;
     2050}
     2051
     2052DLLEXPORT int trace_set_meta_packet_cb(libtrace_callback_set_t *cbset,
     2053                fn_cb_meta_packet handler) {
     2054        cbset->message_meta_packet = handler;
    20372055        return 0;
    20382056}
Note: See TracChangeset for help on using the changeset viewer.