source: lib/data-struct/vector.h @ fac8c46

Last change on this file since fac8c46 was fac8c46, checked in by Richard Sanger <rsangerarj@…>, 8 years ago

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.

  • Property mode set to 100644
File size: 1.2 KB
1#include <pthread.h>
2/* Need libtrace.h for DLLEXPORT defines */
3#include "../libtrace.h"
8typedef void (*vector_data_fn)(void *data);
9typedef struct libtrace_vector {
10        size_t max_size;
11        size_t size;
12        size_t element_size;
13        char *elements; // Means we can use array indexing
14        pthread_mutex_t lock;
15} libtrace_vector_t;
17DLLEXPORT void libtrace_vector_init(libtrace_vector_t *v, size_t element_size);
18DLLEXPORT void libtrace_vector_push_back(libtrace_vector_t *v, void *d);
19DLLEXPORT size_t libtrace_vector_get_size(libtrace_vector_t *v);
20DLLEXPORT int libtrace_vector_get(libtrace_vector_t *v, size_t location, void *d);
21DLLEXPORT void libtrace_vector_append(libtrace_vector_t *dest, libtrace_vector_t *src);
22DLLEXPORT void libtrace_vector_destroy(libtrace_vector_t *v);
23DLLEXPORT void libtrace_zero_vector(libtrace_vector_t *v);
24DLLEXPORT int libtrace_vector_remove_front(libtrace_vector_t *v);
25DLLEXPORT void libtrace_vector_empty(libtrace_vector_t *v);
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);
Note: See TracBrowser for help on using the repository browser.