Changeset fac8c46 for lib/data-struct


Ignore:
Timestamp:
05/20/14 03:25:13 (8 years ago)
Author:
Richard Sanger <rsangerarj@…>
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:
82facc5
Parents:
a5662447
Message:

Tidies up the pausing so that it now works as expected and a trace can easily be paused and restarted.
Ensures that packets will not be lost if pause is called on a file, any queued packets will be read (a message is sent allowing the user to drop these packets if they are unwanted).
Differentiates packets from other results in the queues to the reducer/reporter and makes a copy of the packets in result queues when pausing

  • this is needed to ensure that bad memory isn't referenced if a zero-copy trace is paused by closing sockets/associated data like in the case of ring:.

Fixed up the re-starting of traces which hadn't been finished to account for different configurations.
Adds a 'state' to libtrace to handle the state of parallel traces, rather than hacking around the existing 'started' boolean. Also provides two levels of checks for consistency if the trace is using existing that are checking started.

Various other bug fixes and tidy ups.

Location:
lib/data-struct
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lib/data-struct/deque.c

    read9478 rfac8c46  
    164164        q->size = q->element_size = 0;
    165165}
     166
     167DLLEXPORT void libtrace_deque_apply_function(libtrace_queue_t *q, deque_data_fn fn)
     168{
     169        list_node_t *n;
     170        assert(q->element_size == sizeof(libtrace_result_t));
     171        assert(pthread_mutex_lock(&q->lock) == 0);
     172        n = q->head;
     173        for (n = q->head; n != NULL; n = n->next) {
     174                (*fn)(&n->data);
     175        }
     176        assert(pthread_mutex_unlock(&q->lock) == 0);
     177}
  • lib/data-struct/deque.h

    read9478 rfac8c46  
    66
    77typedef struct list_node list_node_t;
     8typedef void (*deque_data_fn)(void *data);
    89typedef struct libtrace_queue {
    910        list_node_t * head;
     
    2526DLLEXPORT void libtrace_zero_deque(libtrace_queue_t *q);
    2627
     28// Apply a given function to every data item, while keeping the entire
     29// structure locked from external modifications
     30DLLEXPORT void libtrace_deque_apply_function(libtrace_queue_t *q, deque_data_fn fn);
     31
    2732#endif
  • lib/data-struct/message_queue.c

    read9478 rfac8c46  
    1818inline void libtrace_message_queue_init(libtrace_message_queue_t *mq, size_t message_len)
    1919{
     20        assert(message_len);
    2021        assert(pipe(mq->pipefd) != -1);
    2122        mq->message_count = 0;
     
    4344{
    4445        int ret;
     46        assert(mq->message_len);
    4547        assert(write(mq->pipefd[1], message, mq->message_len) == (int) mq->message_len);
    4648        // Update after we've written
  • lib/data-struct/vector.c

    read9478 rfac8c46  
    113113        v->size = 0;
    114114        v->element_size = 0;
    115         v->elements = NULL;     
     115        v->elements = NULL;
    116116}
    117117
     
    121121        assert(pthread_mutex_unlock(&v->lock) == 0);
    122122}
     123
     124
     125DLLEXPORT void libtrace_vector_apply_function(libtrace_vector_t *v, vector_data_fn fn)
     126{
     127        size_t cur;
     128        assert(pthread_mutex_lock(&v->lock) == 0);
     129        for (cur = 0; cur < v->size; cur++) {
     130                (*fn)(&v->elements[cur*v->element_size]);
     131        }
     132        assert(pthread_mutex_unlock(&v->lock) == 0);
     133}
  • lib/data-struct/vector.h

    rabda273 rfac8c46  
    66#define LIBTRACE_VECTOR_H
    77
     8typedef void (*vector_data_fn)(void *data);
    89typedef struct libtrace_vector {
    910        size_t max_size;
     
    2324DLLEXPORT int libtrace_vector_remove_front(libtrace_vector_t *v);
    2425DLLEXPORT void libtrace_vector_empty(libtrace_vector_t *v);
     26
     27// For now this is a special case and this doesn't really belong
     28// here, but to do this properly a full lock is required as
     29// multiple items are changed
     30DLLEXPORT void libtrace_vector_apply_function(libtrace_vector_t *v, vector_data_fn fn);
     31
    2532#endif
Note: See TracChangeset for help on using the changeset viewer.