+static struct lttng_pipe *_pipe_create(void)
+{
+ int ret;
+ struct lttng_pipe *p;
+
+ p = zmalloc(sizeof(*p));
+ if (!p) {
+ PERROR("zmalloc pipe create");
+ goto end;
+ }
+ p->fd[0] = p->fd[1] = -1;
+
+ ret = pthread_mutex_init(&p->read_mutex, NULL);
+ if (ret) {
+ PERROR("pthread_mutex_init read lock pipe create");
+ goto error_destroy;
+ }
+ ret = pthread_mutex_init(&p->write_mutex, NULL);
+ if (ret) {
+ PERROR("pthread_mutex_init write lock pipe create");
+ goto error_destroy_rmutex;
+ }
+end:
+ return p;
+error_destroy_rmutex:
+ (void) pthread_mutex_destroy(&p->read_mutex);
+error_destroy:
+ free(p);
+ return NULL;
+}
+
+static int _pipe_set_flags(struct lttng_pipe *pipe, int flags)
+{
+ int i, ret = 0;
+
+ if (!flags) {
+ goto end;
+ }
+
+ for (i = 0; i < 2; i++) {
+ ret = fcntl(pipe->fd[i], F_SETFD, flags);
+ if (ret < 0) {
+ PERROR("fcntl lttng pipe %d", flags);
+ goto end;
+ }
+ }
+end:
+ return ret;
+}