From 840a73344734b584f7033a2b76628b28c2fa57bf Mon Sep 17 00:00:00 2001 From: Christian Babeux Date: Sun, 2 Dec 2012 20:41:43 -0500 Subject: [PATCH] Cygwin: Introduce new LTTNG_UST_STREAM_PIPE command to open wakeup pipe Normally, the userspace tracer open the wakeup pipe, and the resulting fd is passed to the consumer via the session daemon. Since we can't pass fds via UNIX socket, the pipe need to be opened separately in the tracer and in the consumer. The only way to open the write side of a named pipe *before* the read side without blocking is to open it in read/write mode. This is supported on Linux, but POSIX leave this behavior undefined [1]. The Cygwin named pipe implementation doesn't seem to allow multiple readers/writers on a named pipe. Opening a pipe in RW mode in the tracer and then opening the read side in the consumer won't work because the consumer will get a "Device or ressource busy" error. Thus arise the need to open the named pipe read side *before* the write side. In order to accomplish this task, a new command must be introduced to signal to the tracer that a specific named pipe should be opened in write mode. Proper care must be taken to issue this command *after* the named pipe paths have been sent to the consumer or else the sessiond or tracer will block indefinitely. Signed-off-by: Christian Babeux --- src/bin/lttng-sessiond/lttng-ust-abi.h | 2 +- src/bin/lttng-sessiond/lttng-ust-ctl.h | 1 + src/bin/lttng-sessiond/ust-app.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/lttng-ust-abi.h b/src/bin/lttng-sessiond/lttng-ust-abi.h index c54ef2fbf..2e08233e2 100644 --- a/src/bin/lttng-sessiond/lttng-ust-abi.h +++ b/src/bin/lttng-sessiond/lttng-ust-abi.h @@ -182,7 +182,7 @@ struct lttng_ust_calibrate { #define LTTNG_UST_STREAM _UST_CMD(0x60) #define LTTNG_UST_EVENT \ _UST_CMDW(0x61, struct lttng_ust_event) - +#define LTTNG_UST_STREAM_PIPE _UST_CMD(0x62) /* Event and Channel FD commands */ #define LTTNG_UST_CONTEXT \ _UST_CMDW(0x70, struct lttng_ust_context) diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h index a4f9c3fb4..43e3f8deb 100644 --- a/src/bin/lttng-sessiond/lttng-ust-ctl.h +++ b/src/bin/lttng-sessiond/lttng-ust-ctl.h @@ -26,6 +26,7 @@ int ustctl_create_session(int sock); int ustctl_open_metadata(int sock, int session_handle, struct lttng_ust_channel_attr *chops, struct lttng_ust_object_data **metadata_data); +int ustctl_open_wait_pipe(int sock, struct lttng_ust_object *channel_data); int ustctl_create_channel(int sock, int session_handle, struct lttng_ust_channel_attr *chops, struct lttng_ust_object_data **channel_data); diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 5380450f6..5c66776d4 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -2055,6 +2055,31 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) goto error_rcu_unlock; } + /* Ask UST to open the write side of the wait pipe */ + DBG("Asking UST to open metadata stream wait pipe path: %s\n", + ua_sess->metadata->stream_obj->wait_pipe_path); + + ret = ustctl_open_wait_pipe(app->sock, ua_sess->metadata->obj); + + if (ret < 0) { + ERR("Asking UST to open wait_pipe failed"); + } + + /* each channel */ + cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan, + node.node) { + + DBG("Asking UST to open channel wait pipe path: %s\n", + ua_chan->obj->wait_pipe_path); + + ret = ustctl_open_wait_pipe(app->sock, ua_chan->obj); + + if (ret < 0) { + ERR("Asking UST to open wait_pipe failed for wait pipe: %s", + ua_chan->obj->wait_pipe_path); + } + } + skip_setup: /* This start the UST tracing */ ret = ustctl_start_session(app->sock, ua_sess->handle); -- 2.34.1