uint32_t cmd;
char padding[USTCOMM_MSG_PADDING1];
union {
- struct lttng_ust_event_notifier event_notifier;
struct lttng_ust_channel channel;
struct lttng_ust_stream stream;
struct lttng_ust_event event;
struct lttng_ust_counter counter;
struct lttng_ust_counter_global counter_global;
struct lttng_ust_counter_cpu counter_cpu;
+ /*
+ * For LTTNG_UST_EVENT_NOTIFIER_CREATE, a struct
+ * lttng_ust_event_notifier implicitly follows struct
+ * ustcomm_ust_msg.
+ */
+ struct {
+ /* Length of struct lttng_ust_event_notifier */
+ uint32_t len;
+ } event_notifier;
char padding[USTCOMM_MSG_PADDING2];
} u;
} LTTNG_PACKED;
struct ustcomm_ust_msg lum;
struct ustcomm_ust_reply lur;
struct lttng_ust_object_data *event_notifier_data;
+ ssize_t len;
int ret;
if (!event_notifier_group || !_event_notifier_data)
memset(&lum, 0, sizeof(lum));
lum.handle = event_notifier_group->handle;
lum.cmd = LTTNG_UST_EVENT_NOTIFIER_CREATE;
+ lum.u.event_notifier.len = sizeof(*event_notifier);
- strncpy(lum.u.event_notifier.event.name, event_notifier->event.name,
- LTTNG_UST_SYM_NAME_LEN);
- lum.u.event_notifier.event.instrumentation = event_notifier->event.instrumentation;
- lum.u.event_notifier.event.loglevel_type = event_notifier->event.loglevel_type;
- lum.u.event_notifier.event.loglevel = event_notifier->event.loglevel;
- lum.u.event_notifier.event.token = event_notifier->event.token;
- lum.u.event_notifier.error_counter_index = event_notifier->error_counter_index;
ret = ustcomm_send_app_cmd(sock, &lum, &lur);
if (ret) {
free(event_notifier_data);
return ret;
}
+ /* Send struct lttng_ust_event_notifier */
+ len = ustcomm_send_unix_sock(sock, event_notifier, sizeof(*event_notifier));
+ if (len != sizeof(*event_notifier)) {
+ if (len < 0)
+ return len;
+ else
+ return -EIO;
+ }
event_notifier_data->handle = lur.ret_val;
DBG("received event_notifier handle %u", event_notifier_data->handle);
*_event_notifier_data = event_notifier_data;
ret = -ENOSYS;
break;
}
+ case LTTNG_UST_EVENT_NOTIFIER_CREATE:
+ {
+ /* Receive struct lttng_ust_event_notifier */
+ struct lttng_ust_event_notifier event_notifier;
+
+ if (sizeof(event_notifier) != lum->u.event_notifier.len) {
+ DBG("incorrect event notifier data message size: %u", lum->u.event_notifier.len);
+ ret = -EINVAL;
+ goto error;
+ }
+ len = ustcomm_recv_unix_sock(sock, &event_notifier, sizeof(event_notifier));
+ switch (len) {
+ case 0: /* orderly shutdown */
+ ret = 0;
+ goto error;
+ default:
+ if (len == sizeof(event_notifier)) {
+ DBG("event notifier data received");
+ break;
+ } else if (len < 0) {
+ DBG("Receive failed from lttng-sessiond with errno %d", (int) -len);
+ if (len == -ECONNRESET) {
+ ERR("%s remote end closed connection", sock_info->name);
+ ret = len;
+ goto error;
+ }
+ ret = len;
+ goto error;
+ } else {
+ DBG("incorrect event notifier data message size: %zd", len);
+ ret = -EINVAL;
+ goto error;
+ }
+ }
+ if (ops->cmd)
+ ret = ops->cmd(lum->handle, lum->cmd,
+ (unsigned long) &event_notifier,
+ &args, sock_info);
+ else
+ ret = -ENOSYS;
+ break;
+ }
default:
if (ops->cmd)