#include <lttng/lttng.h>
-#include "liblttsessiondcomm.h"
+#include <lttng/lttng-sessiond-comm.h>
#include "lttngerr.h"
#include "lttng-share.h"
static char *tracing_group;
static int connected;
+/*
+ * Copy string from src to dst and enforce null terminated byte.
+ */
+static void copy_string(char *dst, const char *src, size_t len)
+{
+ if (src && dst) {
+ strncpy(dst, src, len);
+ /* Enforce the NULL terminated byte */
+ dst[len - 1] = '\0';
+ }
+}
+
/*
* send_data_sessiond
*
/* Are we in the tracing group ? */
ret = check_tracing_group(tracing_group);
if (ret < 0 && getuid() != 0) {
- if (sprintf(sessiond_sock_path, DEFAULT_HOME_CLIENT_UNIX_SOCK,
- getenv("HOME")) < 0) {
+ if (snprintf(sessiond_sock_path, PATH_MAX,
+ DEFAULT_HOME_CLIENT_UNIX_SOCK,
+ getenv("HOME")) < 0) {
return -ENOMEM;
}
} else {
- strncpy(sessiond_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
- sizeof(DEFAULT_GLOBAL_CLIENT_UNIX_SOCK));
+ copy_string(sessiond_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
+ PATH_MAX);
}
return 0;
}
}
-/*
- * Copy string from src to dst and enforce null terminated byte.
- */
-static void copy_string(char *dst, const char *src, size_t len)
-{
- if (src && dst) {
- strncpy(dst, src, len);
- /* Enforce the NULL terminated byte */
- dst[len - 1] = '\0';
- }
-}
-
/*
* Start tracing for all trace of the session.
*/
return 0;
}
+/*
+ * lttng_calibrate
+ */
+int lttng_calibrate(struct lttng_domain *domain,
+ struct lttng_calibrate *calibrate)
+{
+ int ret;
+
+ copy_lttng_domain(domain);
+
+ memcpy(&lsm.u.calibrate, calibrate, sizeof(struct lttng_calibrate));
+ ret = ask_sessiond(LTTNG_CALIBRATE, NULL);
+
+ return ret;
+}
+
/*
* lttng_check_session_daemon
*
return ret;
}
- /* If socket exist, we consider the daemon started */
+ /* If socket exist, we check if the daemon listens to connect. */
ret = access(sessiond_sock_path, F_OK);
if (ret < 0) {
/* Not alive */
return 0;
}
+ ret = lttcomm_connect_unix_sock(sessiond_sock_path);
+ if (ret < 0) {
+ /* Not alive */
+ return 0;
+ }
+ ret = lttcomm_close_unix_sock(ret);
+ if (ret < 0)
+ perror("lttcomm_close_unix_sock");
+
/* Is alive */
return 1;
}