*/
int lttcomm_connect_unix_sock(const char *pathname)
{
- struct sockaddr_un sun;
- int fd;
+ struct sockaddr_un sun;
+ int fd;
int ret = 1;
- fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
goto error;
}
- memset(&sun, 0, sizeof(sun));
- sun.sun_family = AF_UNIX;
- strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
+ memset(&sun, 0, sizeof(sun));
+ sun.sun_family = AF_UNIX;
+ strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
- ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun));
- if (ret < 0) {
- perror("connect");
+ ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun));
+ if (ret < 0) {
+ perror("connect");
goto error;
- }
+ }
- return fd;
+ return fd;
error:
return -1;
/* Get the error code index from 0 since
* LTTCOMM_OK start at 1000
*/
-#define LTTCOMM_ERR_INDEX(code) code - LTTCOMM_OK
+#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
enum lttcomm_command_type {
LTTNG_CREATE_SESSION,
#include "liblttsessiondcomm.h"
#include "ltt-sessiond.h"
+const char default_home_dir[] = DEFAULT_HOME_DIR;
+const char default_tracing_group[] = DEFAULT_TRACING_GROUP;
+const char default_ust_sock_dir[] = DEFAULT_UST_SOCK_DIR;
+const char default_global_apps_pipe[] = DEFAULT_GLOBAL_APPS_PIPE;
+
/* Static functions */
static int set_signal_handler(void);
static int set_socket_perms(void);
struct ltt_traceable_app *lta;
/* TODO: Something more elegant is needed but fine for now */
- struct {
+ struct {
int reg; /* 1:register, 0:unregister */
- pid_t pid;
- uid_t uid;
- } reg_msg;
+ pid_t pid;
+ uid_t uid;
+ } reg_msg;
/* Notify all applications to register */
notify_apps(default_global_apps_pipe);
{
const char *home_path;
- if ((home_path = (const char*) getenv("HOME")) == NULL) {
+ if ((home_path = (const char *) getenv("HOME")) == NULL) {
home_path = default_home_dir;
}
case SIGINT:
case SIGTERM:
cleanup();
+ break;
default:
break;
}
#ifndef _LTT_SESSIOND_H
#define _LTT_SESSIOND_H
-const char default_home_dir[] = "/tmp";
-const char default_tracing_group[] = "tracing";
-const char default_ust_sock_dir[] = "/tmp/ust-app-socks";
-const char default_global_apps_pipe[] = "/tmp/ust-app-socks/global";
+#define DEFAULT_HOME_DIR "/tmp"
+#define DEFAULT_TRACING_GROUP "/tracing"
+#define DEFAULT_UST_SOCK_DIR "/tmp/ust-app-socks"
+#define DEFAULT_GLOBAL_APPS_PIPE "/tmp/ust-app-socks/global"
+
+extern const char default_home_dir[],
+ default_tracing_group[],
+ default_ust_sock_dir[],
+ default_global_apps_pipe[];
/* LTTng trace representation */
struct ltt_lttng_trace {