+ ret = lttng_ust_objd_unref(lum->handle, 1);
+ break;
+ case LTTNG_UST_FILTER:
+ {
+ /* Receive filter data */
+ struct lttng_ust_filter_bytecode_node *bytecode;
+
+ if (lum->u.filter.data_size > FILTER_BYTECODE_MAX_LEN) {
+ ERR("Filter data size is too large: %u bytes",
+ lum->u.filter.data_size);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ if (lum->u.filter.reloc_offset > lum->u.filter.data_size) {
+ ERR("Filter reloc offset %u is not within data",
+ lum->u.filter.reloc_offset);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ bytecode = zmalloc(sizeof(*bytecode) + lum->u.filter.data_size);
+ if (!bytecode) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ len = ustcomm_recv_unix_sock(sock, bytecode->bc.data,
+ lum->u.filter.data_size);
+ switch (len) {
+ case 0: /* orderly shutdown */
+ ret = 0;
+ free(bytecode);
+ goto error;
+ default:
+ if (len == lum->u.filter.data_size) {
+ DBG("filter 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;
+ free(bytecode);
+ goto error;
+ }
+ ret = len;
+ free(bytecode);
+ goto end;
+ } else {
+ DBG("incorrect filter data message size: %zd", len);
+ ret = -EINVAL;
+ free(bytecode);
+ goto end;
+ }
+ }
+ bytecode->bc.len = lum->u.filter.data_size;
+ bytecode->bc.reloc_offset = lum->u.filter.reloc_offset;
+ bytecode->bc.seqnum = lum->u.filter.seqnum;
+ if (ops->cmd) {
+ ret = ops->cmd(lum->handle, lum->cmd,
+ (unsigned long) bytecode,
+ &args, sock_info);
+ if (ret) {
+ free(bytecode);
+ }
+ /* don't free bytecode if everything went fine. */
+ } else {
+ ret = -ENOSYS;
+ free(bytecode);
+ }
+ break;
+ }
+ case LTTNG_UST_CHANNEL:
+ {
+ void *chan_data;
+ int wakeup_fd;
+
+ len = ustcomm_recv_channel_from_sessiond(sock,
+ &chan_data, lum->u.channel.len,
+ &wakeup_fd);
+ switch (len) {
+ case 0: /* orderly shutdown */
+ ret = 0;
+ goto error;
+ default:
+ if (len == lum->u.channel.len) {
+ DBG("channel 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 end;
+ } else {
+ DBG("incorrect channel data message size: %zd", len);
+ ret = -EINVAL;
+ goto end;
+ }
+ }
+ args.channel.chan_data = chan_data;
+ args.channel.wakeup_fd = wakeup_fd;
+ if (ops->cmd)
+ ret = ops->cmd(lum->handle, lum->cmd,
+ (unsigned long) &lum->u,
+ &args, sock_info);
+ else
+ ret = -ENOSYS;
+ break;
+ }
+ case LTTNG_UST_STREAM:
+ {
+ /* Receive shm_fd, wakeup_fd */
+ ret = ustcomm_recv_stream_from_sessiond(sock,
+ &lum->u.stream.len,
+ &args.stream.shm_fd,
+ &args.stream.wakeup_fd);
+ if (ret) {
+ goto end;
+ }
+ if (ops->cmd)
+ ret = ops->cmd(lum->handle, lum->cmd,
+ (unsigned long) &lum->u,
+ &args, sock_info);
+ else
+ ret = -ENOSYS;