Cygwin: Introduce new LTTNG_UST_STREAM_PIPE command to open wakeup pipe
authorChristian Babeux <christian.babeux@efficios.com>
Mon, 3 Dec 2012 01:41:43 +0000 (20:41 -0500)
committerChristian Babeux <christian.babeux@efficios.com>
Fri, 7 Dec 2012 20:17:55 +0000 (15:17 -0500)
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 <christian.babeux@efficios.com>
src/bin/lttng-sessiond/lttng-ust-abi.h
src/bin/lttng-sessiond/lttng-ust-ctl.h
src/bin/lttng-sessiond/ust-app.c

index c54ef2fbf7040f4663caedc9870ea116c541a894..2e08233e261e5a388cbe90ff7c2764ab3f30dac1 100644 (file)
@@ -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)
index a4f9c3fb4c93ae1350b70f07880666b4c80bccf3..43e3f8deb46d9248c0866d3fe0b46bbf93a07c29 100644 (file)
@@ -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);
index 5380450f643a31cce3fa3e2eb1bb8ca994fb20ff..5c66776d4901c42ed44b19a591f56c32f188147e 100644 (file)
@@ -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);
This page took 0.027963 seconds and 4 git commands to generate.