X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Flttng-kconsumerd.h;h=98771de3ca44ef8cb5f560746c5823535d265ffa;hb=2b0bf86429e59691e549be8a1fee6aa72879c502;hp=8d16d5670e353072e00a608a989579e6149fd47f;hpb=6533b585a3a53a0b52c2da14baec5e874d1bf3bb;p=lttng-tools.git diff --git a/include/lttng/lttng-kconsumerd.h b/include/lttng/lttng-kconsumerd.h index 8d16d5670..98771de3c 100644 --- a/include/lttng/lttng-kconsumerd.h +++ b/include/lttng/lttng-kconsumerd.h @@ -21,6 +21,8 @@ #include #include +#include +#include /* * When the receiving thread dies, we need to have a way to make the polling @@ -79,6 +81,31 @@ struct lttng_kconsumerd_fd { struct lttng_kconsumerd_local_data { /* function to call when data is available on a buffer */ int (*on_buffer_ready)(struct lttng_kconsumerd_fd *kconsumerd_fd); + /* + * function to call when we receive a new fd, it receives a + * newly allocated kconsumerd_fd, depending on the return code + * of this function, the new FD will be handled by the + * application or the library. + * + * Returns: + * > 0 (success, FD is kept by application) + * == 0 (success, FD is left to library) + * < 0 (error) + */ + int (*on_recv_fd)(struct lttng_kconsumerd_fd *kconsumerd_fd); + /* + * function to call when a FD is getting updated by the session + * daemon, this function receives the FD as seen by the session + * daemon (sessiond_fd) and the new state, depending on the + * return code of this function the update of state for the FD + * is handled by the application or the library. + * + * Returns: + * > 0 (success, FD is kept by application) + * == 0 (success, FD is left to library) + * < 0 (error) + */ + int (*on_update_fd)(int sessiond_fd, uint32_t state); /* socket to communicate errors with sessiond */ int kconsumerd_error_socket; /* socket to exchange commands with sessiond */ @@ -98,15 +125,15 @@ struct lttng_kconsumerd_local_data { * - create the should_quit pipe (for signal handler) * - create the thread pipe (for splice) * - * Takes a function pointer as argument, this function is called when data is - * available on a buffer. This function is responsible to do the - * kernctl_get_next_subbuf, read the data with mmap or splice depending on the - * buffer configuration and then kernctl_put_next_subbuf at the end. + * Takes the function pointers to the on_buffer_ready, on_recv_fd, and + * on_update_fd callbacks. * * Returns a pointer to the new context or NULL on error. */ extern struct lttng_kconsumerd_local_data *lttng_kconsumerd_create( - int (*buffer_ready)(struct lttng_kconsumerd_fd *kconsumerd_fd)); + int (*buffer_ready)(struct lttng_kconsumerd_fd *kconsumerd_fd), + int (*recv_fd)(struct lttng_kconsumerd_fd *kconsumerd_fd), + int (*update_fd)(int sessiond_fd, uint32_t state)); /* * Close all fds associated with the instance and free the context. @@ -131,6 +158,24 @@ extern int lttng_kconsumerd_on_read_subbuffer_splice( struct lttng_kconsumerd_local_data *ctx, struct lttng_kconsumerd_fd *kconsumerd_fd, unsigned long len); +/* + * Take a snapshot for a specific fd + * + * Returns 0 on success, < 0 on error + */ +int lttng_kconsumerd_take_snapshot(struct lttng_kconsumerd_local_data *ctx, + struct lttng_kconsumerd_fd *kconsumerd_fd); + +/* + * Get the produced position + * + * Returns 0 on success, < 0 on error + */ +int lttng_kconsumerd_get_produced_snapshot( + struct lttng_kconsumerd_local_data *ctx, + struct lttng_kconsumerd_fd *kconsumerd_fd, + unsigned long *pos); + /* * Send return code to session daemon. *