X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fsession.h;h=fa1d064b6b4e4bbab83f75d048946b8f423d8d22;hp=11f9b9ace8986b0366e046d5787a7803fa38180c;hb=00187dd4ee65fc3057ace02f8c954b9b457de6c4;hpb=5e16da05d15eb413f28dea441e1bc49809cddc9b diff --git a/ltt-sessiond/session.h b/ltt-sessiond/session.h index 11f9b9ace..fa1d064b6 100644 --- a/ltt-sessiond/session.h +++ b/ltt-sessiond/session.h @@ -3,8 +3,8 @@ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * as published by the Free Software Foundation; only version 2 + * of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,42 +19,67 @@ #ifndef _LTT_SESSION_H #define _LTT_SESSION_H -#include -#include +#include +#include + +#include "trace-kernel.h" +#include "trace-ust.h" /* - * FIXME: create a cmd_context structure to pass this kind of - * information around as parameter. Will facilitate multithreaded design - * later. + * Tracing session list + * + * Statically declared in session.c and can be accessed by using + * get_session_list() function that returns the pointer to the list. */ -extern struct ltt_session *current_session; - -/* Global session list */ struct ltt_session_list { + /* + * This lock protects any read/write access to the list and count (which is + * basically the list size). All public functions in session.c acquire this + * lock and release it before returning. If none of those functions are + * used, the lock MUST be acquired in order to iterate or/and do any + * actions on that list. + */ + pthread_mutex_t lock; + + /* + * Number of element in the list. The session list lock MUST be acquired if + * this counter is used when iterating over the session list. + */ + unsigned int count; + + /* Linked list head */ struct cds_list_head head; }; -/* ltt-session - This data structure contains information needed - * to identify a tracing session for both LTTng and UST. +/* + * This data structure contains information needed to identify a tracing + * session for both LTTng and UST. */ struct ltt_session { char *name; - struct cds_list_head list; - uuid_t uuid; + char *path; + struct ltt_kernel_session *kernel_session; struct cds_list_head ust_traces; - struct cds_list_head kernel_traces; unsigned int ust_trace_count; - unsigned int kern_trace_count; - pid_t ust_consumer; - pid_t kernel_consumer; + /* + * Protect any read/write on this session data structure. This lock must be + * acquired *before* using any public functions declared below. Use + * lock_session() and unlock_session() for that. + */ + pthread_mutex_t lock; + struct cds_list_head list; }; /* Prototypes */ -int create_session(char *name, uuid_t *session_id); -int destroy_session(uuid_t *uuid); -void get_lttng_session(struct lttng_session *lt); -struct ltt_session *find_session_by_uuid(uuid_t session_id); +int create_session(char *name, char *path); +int destroy_session(char *name); + +void lock_session(struct ltt_session *session); +void lock_session_list(void); +void unlock_session(struct ltt_session *session); +void unlock_session_list(void); + struct ltt_session *find_session_by_name(char *name); -unsigned int get_session_count(void); +struct ltt_session_list *get_session_list(void); #endif /* _LTT_SESSION_H */