ret = kernctl_add_context(chan->fd, ctx);
if (ret < 0) {
if (errno != EEXIST) {
- perror("add context ioctl");
+ PERROR("add context ioctl");
} else {
/* If EEXIST, we just ignore the error */
ret = 0;
chan->ctx = zmalloc(sizeof(struct lttng_kernel_context));
if (chan->ctx == NULL) {
- perror("zmalloc event context");
+ PERROR("zmalloc event context");
goto error;
}
DBG("Adding context to event %s", event->event->name);
ret = kernctl_add_context(event->fd, ctx);
if (ret < 0) {
- perror("add context ioctl");
+ PERROR("add context ioctl");
goto error;
}
event->ctx = zmalloc(sizeof(struct lttng_kernel_context));
if (event->ctx == NULL) {
- perror("zmalloc event context");
+ PERROR("zmalloc event context");
goto error;
}
/* Kernel tracer session creation */
ret = kernctl_create_session(tracer_fd);
if (ret < 0) {
- perror("ioctl kernel create session");
+ PERROR("ioctl kernel create session");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lks->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
lks->consumer_fds_sent = 0;
/* Kernel tracer channel creation */
ret = kernctl_create_channel(session->fd, &lkc->channel->attr);
if (ret < 0) {
- perror("ioctl kernel create channel");
+ PERROR("ioctl kernel create channel");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lkc->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
/* Add channel to session */
*/
if (ret == 0 && event->event->instrumentation == LTTNG_KERNEL_SYSCALL) {
DBG2("Kernel event syscall creation success");
+ /*
+ * We use fd == -1 to ensure that we never trigger a close of fd
+ * 0.
+ */
+ event->fd = -1;
goto add_list;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(event->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
add_list:
ret = kernctl_disable(chan->fd);
if (ret < 0) {
- perror("disable chan ioctl");
+ PERROR("disable chan ioctl");
ret = errno;
goto error;
}
ret = kernctl_enable(chan->fd);
if (ret < 0 && errno != EEXIST) {
- perror("Enable kernel chan");
+ PERROR("Enable kernel chan");
goto error;
}
ret = kernctl_enable(event->fd);
if (ret < 0 && errno != EEXIST) {
- perror("enable kernel event");
+ PERROR("enable kernel event");
goto error;
}
ret = kernctl_disable(event->fd);
if (ret < 0 && errno != EEXIST) {
- perror("disable kernel event");
+ PERROR("disable kernel event");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lkm->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
session->metadata = lkm;
ret = kernctl_start_session(session->fd);
if (ret < 0) {
- perror("ioctl start session");
+ PERROR("ioctl start session");
goto error;
}
ret = kernctl_wait_quiescent(fd);
if (ret < 0) {
- perror("wait quiescent ioctl");
+ PERROR("wait quiescent ioctl");
ERR("Kernel quiescent wait failed");
}
}
ret = kernctl_calibrate(fd, calibrate);
if (ret < 0) {
- perror("calibrate ioctl");
+ PERROR("calibrate ioctl");
return -1;
}
DBG("Flushing channel stream %d", stream->fd);
ret = kernctl_buffer_flush(stream->fd);
if (ret < 0) {
- perror("ioctl");
+ PERROR("ioctl");
ERR("Fail to flush buffer for stream %d (ret: %d)",
stream->fd, ret);
}
int ret;
struct ltt_kernel_stream *lks;
- while ((ret = kernctl_create_stream(channel->fd)) > 0) {
+ while ((ret = kernctl_create_stream(channel->fd)) >= 0) {
lks = trace_kernel_create_stream();
if (lks == NULL) {
- close(ret);
+ ret = close(ret);
+ if (ret) {
+ PERROR("close");
+ }
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lks->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
ret = asprintf(&lks->pathname, "%s/%s_%d",
channel->pathname, channel->channel->name, channel->stream_count);
if (ret < 0) {
- perror("asprintf kernel create stream");
+ PERROR("asprintf kernel create stream");
goto error;
}
ret = kernctl_create_stream(session->metadata->fd);
if (ret < 0) {
- perror("kernel create metadata stream");
+ PERROR("kernel create metadata stream");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(session->metadata_stream_fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
return 0;
*/
ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
{
- int fd, pos;
+ int fd, pos, ret;
char *event;
size_t nbmem, count = 0;
ssize_t size;
fd = kernctl_tracepoint_list(tracer_fd);
if (fd < 0) {
- perror("kernel tracepoint list");
+ PERROR("kernel tracepoint list");
goto error;
}
fp = fdopen(fd, "r");
if (fp == NULL) {
- perror("kernel tracepoint list fdopen");
+ PERROR("kernel tracepoint list fdopen");
goto error_fp;
}
nbmem <<= 1;
elist = realloc(elist, nbmem * sizeof(struct lttng_event));
if (elist == NULL) {
- perror("realloc list events");
+ PERROR("realloc list events");
count = -ENOMEM;
goto end;
}
*events = elist;
DBG("Kernel list events done (%zu events)", count);
end:
- fclose(fp); /* closes both fp and fd */
+ ret = fclose(fp); /* closes both fp and fd */
+ if (ret) {
+ PERROR("fclose");
+ }
return count;
error_fp:
- close(fd);
+ ret = close(fd);
+ if (ret) {
+ PERROR("close");
+ }
error:
return -1;
}
/* Ignore error, we don't really care */
}
}
- fclose(fp);
+ ret = fclose(fp);
+ if (ret) {
+ PERROR("fclose");
+ }
end_boot_id:
-
return 0;
}
static char wait_shm_path[PATH_MAX];
/* Sockets and FDs */
-static int client_sock;
-static int apps_sock;
-static int kernel_tracer_fd;
-static int kernel_poll_pipe[2];
+static int client_sock = -1;
+static int apps_sock = -1;
+static int kernel_tracer_fd = -1;
+static int kernel_poll_pipe[2] = { -1, -1 };
/*
* Quit pipe for all threads. This permits a single cancellation point
* for all threads when receiving an event on the pipe.
*/
-static int thread_quit_pipe[2];
+static int thread_quit_pipe[2] = { -1, -1 };
/*
* This pipe is used to inform the thread managing application communication
* that a command is queued and ready to be processed.
*/
-static int apps_cmd_pipe[2];
+static int apps_cmd_pipe[2] = { -1, -1 };
/* Pthread, Mutexes and Semaphores */
static pthread_t apps_thread;
*/
static void cleanup(void)
{
- int ret;
+ int ret, i;
char *cmd;
struct ltt_session *sess, *stmp;
if (is_root && !opt_no_kernel) {
DBG2("Closing kernel fd");
- close(kernel_tracer_fd);
+ if (kernel_tracer_fd >= 0) {
+ ret = close(kernel_tracer_fd);
+ if (ret) {
+ PERROR("close");
+ }
+ }
DBG("Unloading kernel modules");
modprobe_remove_lttng_all();
}
- close(thread_quit_pipe[0]);
- close(thread_quit_pipe[1]);
+ /*
+ * Closing all pipes used for communication between threads.
+ */
+ for (i = 0; i < 2; i++) {
+ if (kernel_poll_pipe[i] >= 0) {
+ ret = close(kernel_poll_pipe[i]);
+ if (ret) {
+ PERROR("close");
+ }
+
+ }
+ }
+ for (i = 0; i < 2; i++) {
+ if (thread_quit_pipe[i] >= 0) {
+ ret = close(thread_quit_pipe[i]);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+ }
+ for (i = 0; i < 2; i++) {
+ if (apps_cmd_pipe[i] >= 0) {
+ ret = close(apps_cmd_pipe[i]);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+ }
/* <fun> */
DBG("%c[%d;%dm*** assert failed :-) *** ==> %c[%dm%c[%d;%dm"
DBG("Sending channel %d to consumer", lkm.u.channel.channel_key);
ret = lttcomm_send_unix_sock(sock, &lkm, sizeof(lkm));
if (ret < 0) {
- perror("send consumer channel");
+ PERROR("send consumer channel");
goto error;
}
DBG("Sending stream %d to consumer", lkm.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lkm, sizeof(lkm));
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
ret = lttcomm_send_fds_unix_sock(sock, &stream->fd, 1);
if (ret < 0) {
- perror("send consumer stream ancillary data");
+ PERROR("send consumer stream ancillary data");
goto error;
}
}
DBG("Sending metadata channel %d to consumer", lkm.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lkm, sizeof(lkm));
if (ret < 0) {
- perror("send consumer channel");
+ PERROR("send consumer channel");
goto error;
}
DBG("Sending metadata stream %d to consumer", lkm.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lkm, sizeof(lkm));
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
ret = lttcomm_send_fds_unix_sock(sock, &session->metadata_stream_fd, 1);
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
}
cmd_ctx->llm = zmalloc(sizeof(struct lttcomm_lttng_msg) + buf_size);
if (cmd_ctx->llm == NULL) {
- perror("zmalloc");
+ PERROR("zmalloc");
ret = -ENOMEM;
goto error;
}
ret = create_thread_poll_set(&events, 2);
if (ret < 0) {
- goto error;
+ goto error_poll_create;
}
ret = lttng_poll_add(&events, kernel_poll_pipe[0], LPOLLIN);
}
error:
- DBG("Kernel thread dying");
- close(kernel_poll_pipe[0]);
- close(kernel_poll_pipe[1]);
-
lttng_poll_clean(&events);
-
+error_poll_create:
+ DBG("Kernel thread dying");
return NULL;
}
*/
static void *thread_manage_consumer(void *data)
{
- int sock = 0, i, ret, pollfd;
+ int sock = -1, i, ret, pollfd;
uint32_t revents, nb_fd;
enum lttcomm_return_code code;
struct lttng_poll_event events;
ret = lttcomm_listen_unix_sock(consumer_data->err_sock);
if (ret < 0) {
- goto error;
+ goto error_listen;
}
/*
*/
ret = create_thread_poll_set(&events, 2);
if (ret < 0) {
- goto error;
+ goto error_poll;
}
ret = lttng_poll_add(&events, consumer_data->err_sock, LPOLLIN | LPOLLRDHUP);
ERR("consumer return code : %s", lttcomm_get_readable_code(-code));
error:
- DBG("consumer thread dying");
- close(consumer_data->err_sock);
- close(consumer_data->cmd_sock);
- close(sock);
+ if (consumer_data->err_sock >= 0) {
+ ret = close(consumer_data->err_sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+ if (consumer_data->cmd_sock >= 0) {
+ ret = close(consumer_data->cmd_sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+ if (sock >= 0) {
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
unlink(consumer_data->err_unix_sock_path);
unlink(consumer_data->cmd_unix_sock_path);
consumer_data->pid = 0;
lttng_poll_clean(&events);
+error_poll:
+error_listen:
+ DBG("consumer thread cleanup completed");
return NULL;
}
ret = create_thread_poll_set(&events, 2);
if (ret < 0) {
- goto error;
+ goto error_poll_create;
}
ret = lttng_poll_add(&events, apps_cmd_pipe[0], LPOLLIN | LPOLLRDHUP);
/* Empty pipe */
ret = read(apps_cmd_pipe[0], &ust_cmd, sizeof(ust_cmd));
if (ret < 0 || ret < sizeof(ust_cmd)) {
- perror("read apps cmd pipe");
+ PERROR("read apps cmd pipe");
goto error;
}
}
error:
- DBG("Application communication apps dying");
- close(apps_cmd_pipe[0]);
- close(apps_cmd_pipe[1]);
-
lttng_poll_clean(&events);
-
+error_poll_create:
+ DBG("Application communication apps thread cleanup complete");
rcu_thread_offline();
rcu_unregister_thread();
return NULL;
ret = write(apps_cmd_pipe[1], ust_cmd,
sizeof(struct ust_command));
if (ret < 0) {
- perror("write apps cmd pipe");
+ PERROR("write apps cmd pipe");
if (errno == EBADF) {
/*
* We can't inform the application thread to process
*/
static void *thread_registration_apps(void *data)
{
- int sock = 0, i, ret, pollfd;
+ int sock = -1, i, ret, pollfd;
uint32_t revents, nb_fd;
struct lttng_poll_event events;
/*
ret = lttcomm_listen_unix_sock(apps_sock);
if (ret < 0) {
- goto error;
+ goto error_listen;
}
/*
*/
ret = create_thread_poll_set(&events, 2);
if (ret < 0) {
- goto error;
+ goto error_create_poll;
}
/* Add the application registration socket */
ret = lttng_poll_add(&events, apps_sock, LPOLLIN | LPOLLRDHUP);
if (ret < 0) {
- goto error;
+ goto error_poll_add;
}
/* Notify all applications to register */
/* Create UST registration command for enqueuing */
ust_cmd = zmalloc(sizeof(struct ust_command));
if (ust_cmd == NULL) {
- perror("ust command zmalloc");
+ PERROR("ust command zmalloc");
goto error;
}
sizeof(struct ust_register_msg));
if (ret < 0 || ret < sizeof(struct ust_register_msg)) {
if (ret < 0) {
- perror("lttcomm_recv_unix_sock register apps");
+ PERROR("lttcomm_recv_unix_sock register apps");
} else {
ERR("Wrong size received on apps register");
}
free(ust_cmd);
- close(sock);
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
+ sock = -1;
continue;
}
}
error:
- DBG("UST Registration thread dying");
-
/* Notify that the registration thread is gone */
notify_ust_apps(0);
- close(apps_sock);
- close(sock);
+ if (apps_sock >= 0) {
+ ret = close(apps_sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+ if (clock >= 0) {
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
unlink(apps_unix_sock_path);
+error_poll_add:
lttng_poll_clean(&events);
+error_listen:
+error_create_poll:
+ DBG("UST Registration thread cleanup complete");
return NULL;
}
break;
}
default:
- perror("unknown consumer type");
+ PERROR("unknown consumer type");
exit(EXIT_FAILURE);
}
if (errno != 0) {
- perror("kernel start consumer exec");
+ PERROR("kernel start consumer exec");
}
exit(EXIT_FAILURE);
} else if (pid > 0) {
ret = pid;
} else {
- perror("start consumer fork");
+ PERROR("start consumer fork");
ret = -errno;
}
error:
error_version:
modprobe_remove_lttng_control();
- close(kernel_tracer_fd);
- kernel_tracer_fd = 0;
+ ret = close(kernel_tracer_fd);
+ if (ret) {
+ PERROR("close");
+ }
+ kernel_tracer_fd = -1;
return LTTCOMM_KERN_VERSION;
error_modules:
- close(kernel_tracer_fd);
+ ret = close(kernel_tracer_fd);
+ if (ret) {
+ PERROR("close");
+ }
error_open:
modprobe_remove_lttng_control();
error:
WARN("No kernel tracer available");
- kernel_tracer_fd = 0;
+ kernel_tracer_fd = -1;
return LTTCOMM_KERN_NA;
}
*/
ret = notify_thread_pipe(kernel_poll_pipe[1]);
if (ret < 0) {
- perror("write kernel poll pipe");
+ PERROR("write kernel poll pipe");
}
ret = session_destroy(session);
}
/* Kernel tracer check */
- if (kernel_tracer_fd == 0) {
+ if (kernel_tracer_fd == -1) {
/* Basically, load kernel tracer modules */
ret = init_kernel_tracer();
if (ret != 0) {
*/
static void *thread_manage_clients(void *data)
{
- int sock = 0, ret, i, pollfd;
+ int sock = -1, ret, i, pollfd;
uint32_t revents, nb_fd;
struct command_ctx *cmd_ctx = NULL;
struct lttng_poll_event events;
/* Allocate context command to process the client request */
cmd_ctx = zmalloc(sizeof(struct command_ctx));
if (cmd_ctx == NULL) {
- perror("zmalloc cmd_ctx");
+ PERROR("zmalloc cmd_ctx");
goto error;
}
/* Allocate data buffer for reception */
cmd_ctx->lsm = zmalloc(sizeof(struct lttcomm_session_msg));
if (cmd_ctx->lsm == NULL) {
- perror("zmalloc cmd_ctx->lsm");
+ PERROR("zmalloc cmd_ctx->lsm");
goto error;
}
sizeof(struct lttcomm_session_msg), &cmd_ctx->creds);
if (ret <= 0) {
DBG("Nothing recv() from client... continuing");
- close(sock);
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
+ sock = -1;
free(cmd_ctx);
continue;
}
}
/* End of transmission */
- close(sock);
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
+ sock = -1;
clean_command_ctx(&cmd_ctx);
}
error:
DBG("Client thread dying");
unlink(client_unix_sock_path);
- close(client_sock);
- close(sock);
+ if (client_sock >= 0) {
+ ret = close(client_sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+ if (sock >= 0) {
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
+ }
lttng_poll_clean(&events);
clean_command_ctx(&cmd_ctx);
ret = chmod(client_unix_sock_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
ERR("Set file permissions failed: %s", client_unix_sock_path);
- perror("chmod");
+ PERROR("chmod");
goto end;
}
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (ret < 0) {
ERR("Set file permissions failed: %s", apps_unix_sock_path);
- perror("chmod");
+ PERROR("chmod");
goto end;
}
ret = chown(rundir, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", rundir);
- perror("chown");
+ PERROR("chown");
}
/* Ensure tracing group can search the run dir */
ret = chmod(rundir, S_IRWXU | S_IXGRP | S_IXOTH);
if (ret < 0) {
ERR("Unable to set permissions on %s", rundir);
- perror("chmod");
+ PERROR("chmod");
}
/* lttng client socket path */
ret = chown(client_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", client_unix_sock_path);
- perror("chown");
+ PERROR("chown");
}
/* kconsumer error socket path */
ret = chown(kconsumer_data.err_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", kconsumer_data.err_unix_sock_path);
- perror("chown");
+ PERROR("chown");
}
/* 64-bit ustconsumer error socket path */
ret = chown(ustconsumer64_data.err_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", ustconsumer64_data.err_unix_sock_path);
- perror("chown");
+ PERROR("chown");
}
/* 32-bit ustconsumer compat32 error socket path */
ret = chown(ustconsumer32_data.err_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", ustconsumer32_data.err_unix_sock_path);
- perror("chown");
+ PERROR("chown");
}
DBG("All permissions are set");
/*
* Create the pipe used to wake up the kernel thread.
+ * Closed in cleanup().
*/
static int create_kernel_poll_pipe(void)
{
/*
* Create the application command pipe to wake thread_manage_apps.
+ * Closed in cleanup().
*/
static int create_apps_cmd_pipe(void)
{
sigset_t sigset;
if ((ret = sigemptyset(&sigset)) < 0) {
- perror("sigemptyset");
+ PERROR("sigemptyset");
return ret;
}
sa.sa_mask = sigset;
sa.sa_flags = 0;
if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
- perror("sigaction");
+ PERROR("sigaction");
return ret;
}
if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
- perror("sigaction");
+ PERROR("sigaction");
return ret;
}
if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
- perror("sigaction");
+ PERROR("sigaction");
return ret;
}
ret = setrlimit(RLIMIT_NOFILE, &lim);
if (ret < 0) {
- perror("failed to set open files limit");
+ PERROR("failed to set open files limit");
}
}
if (opt_daemon) {
ret = daemon(0, 0);
if (ret < 0) {
- perror("daemon");
+ PERROR("daemon");
goto error;
}
}
ret = pthread_create(&client_thread, NULL,
thread_manage_clients, (void *) NULL);
if (ret != 0) {
- perror("pthread_create clients");
+ PERROR("pthread_create clients");
goto exit_client;
}
ret = pthread_create(&dispatch_thread, NULL,
thread_dispatch_ust_registration, (void *) NULL);
if (ret != 0) {
- perror("pthread_create dispatch");
+ PERROR("pthread_create dispatch");
goto exit_dispatch;
}
ret = pthread_create(®_apps_thread, NULL,
thread_registration_apps, (void *) NULL);
if (ret != 0) {
- perror("pthread_create registration");
+ PERROR("pthread_create registration");
goto exit_reg_apps;
}
ret = pthread_create(&apps_thread, NULL,
thread_manage_apps, (void *) NULL);
if (ret != 0) {
- perror("pthread_create apps");
+ PERROR("pthread_create apps");
goto exit_apps;
}
ret = pthread_create(&kernel_thread, NULL,
thread_manage_kernel, (void *) NULL);
if (ret != 0) {
- perror("pthread_create kernel");
+ PERROR("pthread_create kernel");
goto exit_kernel;
}
ret = pthread_join(kernel_thread, &status);
if (ret != 0) {
- perror("pthread_join");
+ PERROR("pthread_join");
goto error; /* join error, exit without cleanup */
}
exit_kernel:
ret = pthread_join(apps_thread, &status);
if (ret != 0) {
- perror("pthread_join");
+ PERROR("pthread_join");
goto error; /* join error, exit without cleanup */
}
exit_apps:
ret = pthread_join(reg_apps_thread, &status);
if (ret != 0) {
- perror("pthread_join");
+ PERROR("pthread_join");
goto error; /* join error, exit without cleanup */
}
exit_reg_apps:
ret = pthread_join(dispatch_thread, &status);
if (ret != 0) {
- perror("pthread_join");
+ PERROR("pthread_join");
goto error; /* join error, exit without cleanup */
}
exit_dispatch:
ret = pthread_join(client_thread, &status);
if (ret != 0) {
- perror("pthread_join");
+ PERROR("pthread_join");
goto error; /* join error, exit without cleanup */
}
ret = join_consumer_thread(&kconsumer_data);
if (ret != 0) {
- perror("join_consumer");
+ PERROR("join_consumer");
goto error; /* join error, exit without cleanup */
}
"/sbin/modprobe -r -q %s",
kern_modules_list[i].name);
if (ret < 0) {
- perror("snprintf modprobe -r");
+ PERROR("snprintf modprobe -r");
goto error;
}
modprobe[sizeof(modprobe) - 1] = '\0';
kern_modules_list[i].required ? "" : "-q ",
kern_modules_list[i].name);
if (ret < 0) {
- perror("snprintf modprobe");
+ PERROR("snprintf modprobe");
goto error;
}
modprobe[sizeof(modprobe) - 1] = '\0';
/* Allocate session data structure */
new_session = zmalloc(sizeof(struct ltt_session));
if (new_session == NULL) {
- perror("zmalloc");
+ PERROR("zmalloc");
ret = LTTCOMM_FATAL;
goto error_malloc;
}
ret = chown(shm_path, 0, 0);
if (ret < 0) {
if (errno != ENOENT) {
- perror("chown wait shm");
+ PERROR("chown wait shm");
goto error;
}
}
ret = chown(shm_path, getuid(), getgid());
if (ret < 0) {
if (errno != ENOENT) {
- perror("chown wait shm");
+ PERROR("chown wait shm");
goto error;
}
}
ret = chmod(shm_path, mode);
if (ret < 0) {
if (errno != ENOENT) {
- perror("chmod wait shm");
+ PERROR("chmod wait shm");
goto error;
}
}
*/
wait_shm_fd = shm_open(shm_path, O_RDWR | O_CREAT, mode);
if (wait_shm_fd < 0) {
- perror("shm_open wait shm");
+ PERROR("shm_open wait shm");
goto error;
}
ret = ftruncate(wait_shm_fd, mmap_size);
if (ret < 0) {
- perror("ftruncate wait shm");
+ PERROR("ftruncate wait shm");
exit(EXIT_FAILURE);
}
#ifndef __FreeBSD__
ret = fchmod(wait_shm_fd, mode);
if (ret < 0) {
- perror("fchmod");
+ PERROR("fchmod");
exit(EXIT_FAILURE);
}
#else
/* close shm fd immediately after taking the mmap reference */
ret = close(wait_shm_fd);
if (ret) {
- perror("Error closing fd");
+ PERROR("Error closing fd");
}
if (wait_shm_mmap == MAP_FAILED) {
/* Allocate a new ltt kernel session */
lks = zmalloc(sizeof(struct ltt_kernel_session));
if (lks == NULL) {
- perror("create kernel session zmalloc");
+ PERROR("create kernel session zmalloc");
goto error;
}
/* Set session path */
ret = asprintf(&lks->trace_path, "%s/kernel", path);
if (ret < 0) {
- perror("asprintf kernel traces path");
+ PERROR("asprintf kernel traces path");
goto error;
}
lkc = zmalloc(sizeof(struct ltt_kernel_channel));
if (lkc == NULL) {
- perror("ltt_kernel_channel zmalloc");
+ PERROR("ltt_kernel_channel zmalloc");
goto error;
}
lkc->channel = zmalloc(sizeof(struct lttng_channel));
if (lkc->channel == NULL) {
- perror("lttng_channel zmalloc");
+ PERROR("lttng_channel zmalloc");
goto error;
}
memcpy(lkc->channel, chan, sizeof(struct lttng_channel));
/* Set default trace output path */
ret = asprintf(&lkc->pathname, "%s", path);
if (ret < 0) {
- perror("asprintf kernel create channel");
+ PERROR("asprintf kernel create channel");
goto error;
}
lke = zmalloc(sizeof(struct ltt_kernel_event));
attr = zmalloc(sizeof(struct lttng_kernel_event));
if (lke == NULL || attr == NULL) {
- perror("kernel event zmalloc");
+ PERROR("kernel event zmalloc");
goto error;
}
lkm = zmalloc(sizeof(struct ltt_kernel_metadata));
chan = zmalloc(sizeof(struct lttng_channel));
if (lkm == NULL || chan == NULL) {
- perror("kernel metadata zmalloc");
+ PERROR("kernel metadata zmalloc");
goto error;
}
/* Set default metadata path */
ret = asprintf(&lkm->pathname, "%s/metadata", path);
if (ret < 0) {
- perror("asprintf kernel metadata");
+ PERROR("asprintf kernel metadata");
goto error;
}
lks = zmalloc(sizeof(struct ltt_kernel_stream));
if (lks == NULL) {
- perror("kernel stream zmalloc");
+ PERROR("kernel stream zmalloc");
goto error;
}
*/
void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream)
{
+ int ret;
+
DBG("[trace] Closing stream fd %d", stream->fd);
/* Close kernel fd */
- close(stream->fd);
+ ret = close(stream->fd);
+ if (ret) {
+ PERROR("close");
+ }
/* Remove from stream list */
cds_list_del(&stream->list);
*/
void trace_kernel_destroy_event(struct ltt_kernel_event *event)
{
- DBG("[trace] Closing event fd %d", event->fd);
- /* Close kernel fd */
- close(event->fd);
+ int ret;
+
+ if (event->fd >= 0) {
+ DBG("[trace] Closing event fd %d", event->fd);
+ /* Close kernel fd */
+ ret = close(event->fd);
+ if (ret) {
+ PERROR("close");
+ }
+ } else {
+ DBG("[trace] Tearing down event (no associated fd)");
+ }
/* Remove from event list */
cds_list_del(&event->list);
{
struct ltt_kernel_stream *stream, *stmp;
struct ltt_kernel_event *event, *etmp;
+ int ret;
DBG("[trace] Closing channel fd %d", channel->fd);
/* Close kernel fd */
- close(channel->fd);
+ ret = close(channel->fd);
+ if (ret) {
+ PERROR("close");
+ }
/* For each stream in the channel list */
cds_list_for_each_entry_safe(stream, stmp, &channel->stream_list.head, list) {
*/
void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata)
{
+ int ret;
+
DBG("[trace] Closing metadata fd %d", metadata->fd);
/* Close kernel fd */
- close(metadata->fd);
+ ret = close(metadata->fd);
+ if (ret) {
+ PERROR("close");
+ }
free(metadata->conf);
free(metadata->pathname);
void trace_kernel_destroy_session(struct ltt_kernel_session *session)
{
struct ltt_kernel_channel *channel, *ctmp;
+ int ret;
DBG("[trace] Closing session fd %d", session->fd);
/* Close kernel fds */
- close(session->fd);
+ ret = close(session->fd);
+ if (ret) {
+ PERROR("close");
+ }
if (session->metadata_stream_fd != 0) {
DBG("[trace] Closing metadata stream fd %d", session->metadata_stream_fd);
- close(session->metadata_stream_fd);
+ ret = close(session->metadata_stream_fd);
+ if (ret) {
+ PERROR("close");
+ }
}
if (session->metadata != NULL) {
luc = zmalloc(sizeof(struct ltt_ust_channel));
if (luc == NULL) {
- perror("ltt_ust_channel zmalloc");
+ PERROR("ltt_ust_channel zmalloc");
goto error;
}
/* Set trace output path */
ret = snprintf(luc->pathname, PATH_MAX, "%s", path);
if (ret < 0) {
- perror("asprintf ust create channel");
+ PERROR("asprintf ust create channel");
goto error_free_channel;
}
lum = zmalloc(sizeof(struct ltt_ust_metadata));
if (lum == NULL) {
- perror("ust metadata zmalloc");
+ PERROR("ust metadata zmalloc");
goto error;
}
/* Set metadata trace path */
ret = snprintf(lum->pathname, PATH_MAX, "%s/metadata", path);
if (ret < 0) {
- perror("asprintf ust metadata");
+ PERROR("asprintf ust metadata");
goto error_free_metadata;
}
* closing this socket, otherwise an application could re-use the socket ID
* and race with the teardown, using the same hash table entry.
*/
- close(sock);
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
DBG2("UST app pid %d deleted", app->key.pid);
free(app);
int ust_app_register(struct ust_register_msg *msg, int sock)
{
struct ust_app *lta;
+ int ret;
if ((msg->bits_per_long == 64 && ust_consumerd64_fd == -EINVAL)
|| (msg->bits_per_long == 32 && ust_consumerd32_fd == -EINVAL)) {
ERR("Registration failed: application \"%s\" (pid: %d) has "
"%d-bit long, but no consumerd for this long size is available.\n",
msg->name, msg->pid, msg->bits_per_long);
- close(sock);
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
return -EINVAL;
}
if (msg->major != LTTNG_UST_COMM_MAJOR) {
ERR("Registration failed: application \"%s\" (pid: %d) has "
"communication protocol version %u.%u, but sessiond supports 2.x.\n",
msg->name, msg->pid, msg->major, msg->minor);
- close(sock);
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
return -EINVAL;
}
lta = zmalloc(sizeof(struct ust_app));
DBG("Sending channel %d to consumer", lum.u.channel.channel_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer channel");
+ PERROR("send consumer channel");
goto error;
}
fd = uchan->obj->shm_fd;
ret = lttcomm_send_fds_unix_sock(sock, &fd, 1);
if (ret < 0) {
- perror("send consumer channel ancillary data");
+ PERROR("send consumer channel ancillary data");
goto error;
}
DBG("Sending stream %d to consumer", lum.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
fds[1] = stream->obj->wait_fd;
ret = lttcomm_send_fds_unix_sock(sock, fds, 2);
if (ret < 0) {
- perror("send consumer stream ancillary data");
+ PERROR("send consumer stream ancillary data");
goto error;
}
}
DBG("Sending metadata channel %d to consumer", lum.u.channel.channel_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer channel");
+ PERROR("send consumer channel");
goto error;
}
fd = usess->metadata->obj->shm_fd;
ret = lttcomm_send_fds_unix_sock(sock, &fd, 1);
if (ret < 0) {
- perror("send consumer metadata channel");
+ PERROR("send consumer metadata channel");
goto error;
}
DBG("Sending metadata stream %d to consumer", lum.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer metadata stream");
+ PERROR("send consumer metadata stream");
goto error;
}
fds[0] = usess->metadata->stream_obj->shm_fd;
fds[1] = usess->metadata->stream_obj->wait_fd;
ret = lttcomm_send_fds_unix_sock(sock, fds, 2);
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
}
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#define _GNU_SOURCE
#include <stdlib.h>
#include <ctype.h>
* Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define _GNU_SOURCE
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
ret = epoll_create1(flags);
if (ret < 0) {
/* At this point, every error is fatal */
- perror("epoll_create1");
+ PERROR("epoll_create1");
goto error;
}
/* This *must* be freed by using lttng_poll_free() */
events->events = zmalloc(size * sizeof(struct epoll_event));
if (events->events == NULL) {
- perror("zmalloc epoll set");
+ PERROR("zmalloc epoll set");
goto error_close;
}
return 0;
error_close:
- close(events->epfd);
+ ret = close(events->epfd);
+ if (ret) {
+ PERROR("close");
+ }
error:
return -1;
}
goto end;
case ENOSPC:
case EPERM:
- /* Print perror and goto end not failing. Show must go on. */
- perror("epoll_ctl ADD");
+ /* Print PERROR and goto end not failing. Show must go on. */
+ PERROR("epoll_ctl ADD");
goto end;
default:
- perror("epoll_ctl ADD fatal");
+ PERROR("epoll_ctl ADD fatal");
goto error;
}
}
new_size = 2 * events->events_size;
ptr = realloc(events->events, new_size * sizeof(struct epoll_event));
if (ptr == NULL) {
- perror("realloc epoll add");
+ PERROR("realloc epoll add");
goto error;
}
events->events = ptr;
switch (errno) {
case ENOENT:
case EPERM:
- /* Print perror and goto end not failing. Show must go on. */
- perror("epoll_ctl DEL");
+ /* Print PERROR and goto end not failing. Show must go on. */
+ PERROR("epoll_ctl DEL");
goto end;
default:
- perror("epoll_ctl DEL fatal");
+ PERROR("epoll_ctl DEL fatal");
goto error;
}
- perror("epoll_ctl del");
+ PERROR("epoll_ctl del");
goto error;
}
} while (ret == -1 && errno == EINTR);
if (ret < 0) {
/* At this point, every error is fatal */
- perror("epoll_wait");
+ PERROR("epoll_wait");
goto error;
}
ret = read(fd, buf, sizeof(buf));
if (ret < 0) {
- perror("read set max size");
+ PERROR("read set max size");
goto error;
}
DBG("epoll set max size is %d", poll_max_size);
error:
- close(fd);
+ ret = close(fd);
+ if (ret) {
+ PERROR("close");
+ }
}
*/
#ifdef HAVE_EPOLL
#include <sys/epoll.h>
+#include <stdio.h>
/* See man epoll(7) for this define path */
#define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
*/
static inline void lttng_poll_clean(struct lttng_poll_event *events)
{
+ int ret;
+
if (events) {
- close(events->epfd);
+ ret = close(events->epfd);
+ if (ret) {
+ perror("close");
+ }
__lttng_poll_free((void *) events->events);
}
}
goto end;
}
if (stream->out_fd >= 0) {
- close(stream->out_fd);
+ ret = close(stream->out_fd);
+ if (ret) {
+ PERROR("close");
+ }
}
if (stream->wait_fd >= 0 && !stream->wait_fd_is_copy) {
- close(stream->wait_fd);
+ ret = close(stream->wait_fd);
+ if (ret) {
+ PERROR("close");
+ }
}
if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd) {
- close(stream->shm_fd);
+ ret = close(stream->shm_fd);
+ if (ret) {
+ PERROR("close");
+ }
}
if (!--stream->chan->refcount)
free_chan = stream->chan;
}
}
if (channel->wait_fd >= 0 && !channel->wait_fd_is_copy) {
- close(channel->wait_fd);
+ ret = close(channel->wait_fd);
+ if (ret) {
+ PERROR("close");
+ }
}
if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd) {
- close(channel->shm_fd);
+ ret = close(channel->shm_fd);
+ if (ret) {
+ PERROR("close");
+ }
}
free(channel);
end:
int err;
err = close(ctx->consumer_should_quit[i]);
- assert(!err);
+ if (err) {
+ PERROR("close");
+ }
}
error_quit_pipe:
for (i = 0; i < 2; i++) {
int err;
err = close(ctx->consumer_poll_pipe[i]);
- assert(!err);
+ if (err) {
+ PERROR("close");
+ }
}
error_poll_pipe:
free(ctx);
*/
void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx)
{
- close(ctx->consumer_error_socket);
- close(ctx->consumer_thread_pipe[0]);
- close(ctx->consumer_thread_pipe[1]);
- close(ctx->consumer_poll_pipe[0]);
- close(ctx->consumer_poll_pipe[1]);
- close(ctx->consumer_should_quit[0]);
- close(ctx->consumer_should_quit[1]);
+ int ret;
+
+ ret = close(ctx->consumer_error_socket);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(ctx->consumer_thread_pipe[0]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(ctx->consumer_thread_pipe[1]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(ctx->consumer_poll_pipe[0]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(ctx->consumer_poll_pipe[1]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(ctx->consumer_should_quit[0]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(ctx->consumer_should_quit[1]);
+ if (ret) {
+ PERROR("close");
+ }
unlink(ctx->consumer_command_sock_path);
free(ctx);
}
#include <stdio.h>
#include <string.h>
+#ifndef _GNU_SOURCE
+#error "lttng-tools error.h needs _GNU_SOURCE"
+#endif
+
/* Stringify the expansion of a define */
#define XSTR(d) STR(d)
#define STR(s) #s
/*
* Macro for printing message depending on command line option and verbosity.
*/
-#define __lttng_print(type, fmt, args...) \
- do { \
- if (opt_quiet == 0) { \
- if (type == PRINT_MSG) { \
- fprintf(stdout, fmt, ## args); \
- } else if (((type & PRINT_DBG) && opt_verbose == 1) || \
- ((type & (PRINT_DBG | PRINT_DBG2)) && \
- opt_verbose == 2) || \
- ((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
- opt_verbose == 3)) { \
- fprintf(stderr, fmt, ## args); \
- } else if (type & (PRINT_ERR | PRINT_WARN | PRINT_BUG)) { \
- fprintf(stderr, fmt, ## args); \
- } \
- } \
+#define __lttng_print(type, fmt, args...) \
+ do { \
+ if (opt_quiet == 0 && type == PRINT_MSG) { \
+ fprintf(stdout, fmt, ## args); \
+ } else if (opt_quiet == 0 && \
+ (((type & PRINT_DBG) && opt_verbose == 1) || \
+ ((type & (PRINT_DBG | PRINT_DBG2)) && \
+ opt_verbose == 2) || \
+ ((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
+ opt_verbose == 3))) { \
+ fprintf(stderr, fmt, ## args); \
+ } else if (opt_quiet == 0 && (type & (PRINT_WARN))) { \
+ fprintf(stderr, fmt, ## args); \
+ } else if (type & (PRINT_ERR | PRINT_BUG)) { \
+ fprintf(stderr, fmt, ## args); \
+ } \
} while (0);
#define MSG(fmt, args...) \
" [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__)
#define _PERROR(fmt, args...) \
- __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args)
+ __lttng_print(PRINT_ERR, "PERROR: " fmt \
+ " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__)
#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
/*
if (data->gid != getegid()) {
ret = setegid(data->gid);
if (ret < 0) {
- perror("setegid");
+ PERROR("setegid");
return EXIT_FAILURE;
}
}
if (data->uid != geteuid()) {
ret = seteuid(data->uid);
if (ret < 0) {
- perror("seteuid");
+ PERROR("seteuid");
return EXIT_FAILURE;
}
}
writelen = write(data->retval_pipe, &sendret.c[index],
writeleft);
if (writelen < 0) {
- perror("write");
+ PERROR("write");
return EXIT_FAILURE;
}
writeleft -= writelen;
ret = pipe(retval_pipe);
if (ret < 0) {
- perror("pipe");
+ PERROR("pipe");
retval.i = ret;
goto end;
}
MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | LTTNG_MAP_STACK,
-1, 0);
if (child_stack == MAP_FAILED) {
- perror("mmap");
+ PERROR("mmap");
retval.i = -ENOMEM;
goto close_pipe;
}
pid = lttng_clone_files(child_run_as, child_stack + (RUNAS_CHILD_STACK_SIZE / 2),
&run_as_data);
if (pid < 0) {
- perror("clone");
+ PERROR("clone");
retval.i = pid;
goto unmap_stack;
}
do {
readlen = read(retval_pipe[0], &retval.c[index], readleft);
if (readlen < 0) {
- perror("read");
+ PERROR("read");
ret = -1;
break;
}
*/
pid = waitpid(pid, &status, 0);
if (pid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
- perror("wait");
+ PERROR("wait");
retval.i = -1;
}
unmap_stack:
ret = munmap(child_stack, RUNAS_CHILD_STACK_SIZE);
if (ret < 0) {
- perror("munmap");
+ PERROR("munmap");
retval.i = ret;
}
close_pipe:
- close(retval_pipe[0]);
- close(retval_pipe[1]);
+ ret = close(retval_pipe[0]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(retval_pipe[1]);
+ if (ret) {
+ PERROR("close");
+ }
end:
return retval.i;
}
#include <errno.h>
#include <common/defaults.h>
+#include <common/error.h>
#include "sessiond-comm.h"
int lttcomm_connect_unix_sock(const char *pathname)
{
struct sockaddr_un sun;
- int fd;
- int ret;
+ int fd, ret, closeret;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
- perror("socket");
+ PERROR("socket");
ret = fd;
goto error;
}
return fd;
error_connect:
- close(fd);
+ closeret = close(fd);
+ if (closeret) {
+ PERROR("close");
+ }
error:
return ret;
}
/* Blocking call */
new_fd = accept(sock, (struct sockaddr *) &sun, &len);
if (new_fd < 0) {
- perror("accept");
+ PERROR("accept");
}
return new_fd;
/* Create server socket */
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
- perror("socket");
+ PERROR("socket");
goto error;
}
(void) unlink(pathname);
ret = bind(fd, (struct sockaddr *) &sun, sizeof(sun));
if (ret < 0) {
- perror("bind");
+ PERROR("bind");
goto error;
}
ret = listen(sock, LTTNG_SESSIOND_COMM_MAX_LISTEN);
if (ret < 0) {
- perror("listen");
+ PERROR("listen");
}
return ret;
ret = recvmsg(sock, &msg, MSG_WAITALL);
if (ret < 0) {
- perror("recvmsg");
+ PERROR("recvmsg");
}
return ret;
ret = sendmsg(sock, &msg, 0);
if (ret < 0) {
- perror("sendmsg");
+ PERROR("sendmsg");
}
return ret;
*/
int lttcomm_close_unix_sock(int sock)
{
- int ret;
+ int ret, closeret;
/* Shutdown receptions and transmissions */
ret = shutdown(sock, SHUT_RDWR);
if (ret < 0) {
- perror("shutdown");
+ PERROR("shutdown");
}
- close(sock);
+ closeret = close(sock);
+ if (closeret) {
+ PERROR("close");
+ }
return ret;
}
ret = sendmsg(sock, &msg, 0);
if (ret < 0) {
- perror("sendmsg");
+ PERROR("sendmsg");
}
return ret;
}
ret = recvmsg(sock, &msg, 0);
if (ret < 0) {
- perror("recvmsg fds");
+ PERROR("recvmsg fds");
goto end;
}
if (ret != 1) {
ret = sendmsg(sock, &msg, 0);
if (ret < 0) {
- perror("sendmsg");
+ PERROR("sendmsg");
}
return ret;
ret = recvmsg(sock, &msg, 0);
if (ret < 0) {
- perror("recvmsg fds");
+ PERROR("recvmsg fds");
goto end;
}
/* Set socket for credentials retrieval */
ret = setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (ret < 0) {
- perror("setsockopt creds unix sock");
+ PERROR("setsockopt creds unix sock");
}
return ret;
}
stream->buf, &mmap_offset);
if (ret != 0) {
errno = -ret;
- perror("ustctl_get_mmap_read_offset");
+ PERROR("ustctl_get_mmap_read_offset");
goto end;
}
while (len > 0) {
len = 0;
} else if (ret < 0) {
errno = -ret;
- perror("Error in file write");
+ PERROR("Error in file write");
goto end;
}
/* This won't block, but will start writeout asynchronously */
ret = ustctl_snapshot(stream->chan->handle, stream->buf);
if (ret != 0) {
errno = -ret;
- perror("Getting sub-buffer snapshot.");
+ PERROR("Getting sub-buffer snapshot.");
}
return ret;
stream->buf, pos);
if (ret != 0) {
errno = -ret;
- perror("kernctl_snapshot_get_produced");
+ PERROR("kernctl_snapshot_get_produced");
}
return ret;
/* signal the poll thread */
ret = write(ctx->consumer_poll_pipe[1], "4", 1);
if (ret < 0) {
- perror("write consumer poll");
+ PERROR("write consumer poll");
}
end_nosignal:
return 0;
stream->uid, stream->gid);
if (ret < 0) {
ERR("Opening %s", stream->path_name);
- perror("open");
+ PERROR("open");
goto error;
}
stream->out_fd = ret;