X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-comm.c;h=682992ca3d46fe719a8b22cfb761fd86ea47fa70;hb=ab89263ef2f50399e608e74557900aa0a3165a61;hp=59f14050f1b5dfdd4d53dc73d3730d9387a96142;hpb=8406222c45d29b23064d688e33be84894a51baac;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 59f14050..682992ca 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -772,7 +772,7 @@ static int handle_bytecode_recv(struct sock_info *sock_info, int sock, struct ustcomm_ust_msg *lum) { - struct lttng_ust_bytecode_node *bytecode; + struct lttng_ust_bytecode_node *bytecode = NULL; enum lttng_ust_bytecode_node_type type; const struct lttng_ust_objd_ops *ops; uint32_t data_size, data_size_max, reloc_offset; @@ -829,7 +829,7 @@ int handle_bytecode_recv(struct sock_info *sock_info, switch (len) { case 0: /* orderly shutdown */ ret = 0; - goto error_free_bytecode; + goto end; default: if (len == bytecode->bc.len) { DBG("Bytecode %s data received", @@ -842,41 +842,33 @@ int handle_bytecode_recv(struct sock_info *sock_info, ERR("%s remote end closed connection", sock_info->name); ret = len; - goto error_free_bytecode; + goto end; } ret = len; - goto error_free_bytecode; + goto end; } else { DBG("Incorrect %s bytecode data message size: %zd", bytecode_type_str(lum->cmd), len); ret = -EINVAL; - goto error_free_bytecode; + goto end; } } ops = objd_ops(lum->handle); if (!ops) { ret = -ENOENT; - goto error_free_bytecode; + goto end; } - if (ops->cmd) { + if (ops->cmd) ret = ops->cmd(lum->handle, lum->cmd, - (unsigned long) bytecode, + (unsigned long) &bytecode, NULL, sock_info); - if (ret) - goto error_free_bytecode; - /* don't free bytecode if everything went fine. */ - } else { + else ret = -ENOSYS; - goto error_free_bytecode; - } - - goto end; -error_free_bytecode: - free(bytecode); end: + free(bytecode); return ret; } @@ -971,23 +963,18 @@ int handle_message(struct sock_info *sock_info, goto error; } } - if (ops->cmd) { + if (ops->cmd) ret = ops->cmd(lum->handle, lum->cmd, - (unsigned long) node, + (unsigned long) &node, &args, sock_info); - if (ret) { - free(node); - } - /* Don't free exclusion data if everything went fine. */ - } else { + else ret = -ENOSYS; - free(node); - } + free(node); break; } case LTTNG_UST_EVENT_NOTIFIER_GROUP_CREATE: { - int event_notifier_notif_fd; + int event_notifier_notif_fd, close_ret; len = ustcomm_recv_event_notifier_notif_fd_from_sessiond(sock, &event_notifier_notif_fd); @@ -1024,6 +1011,13 @@ int handle_message(struct sock_info *sock_info, &args, sock_info); else ret = -ENOSYS; + if (args.event_notifier_handle.event_notifier_notif_fd >= 0) { + lttng_ust_lock_fd_tracker(); + close_ret = close(args.event_notifier_handle.event_notifier_notif_fd); + lttng_ust_unlock_fd_tracker(); + if (close_ret) + PERROR("close"); + } break; } case LTTNG_UST_CHANNEL: @@ -1065,10 +1059,23 @@ int handle_message(struct sock_info *sock_info, &args, sock_info); else ret = -ENOSYS; + if (args.channel.wakeup_fd >= 0) { + int close_ret; + + lttng_ust_lock_fd_tracker(); + close_ret = close(args.channel.wakeup_fd); + lttng_ust_unlock_fd_tracker(); + args.channel.wakeup_fd = -1; + if (close_ret) + PERROR("close"); + } + free(args.channel.chan_data); break; } case LTTNG_UST_STREAM: { + int close_ret; + /* Receive shm_fd, wakeup_fd */ ret = ustcomm_recv_stream_from_sessiond(sock, NULL, @@ -1084,6 +1091,22 @@ int handle_message(struct sock_info *sock_info, &args, sock_info); else ret = -ENOSYS; + if (args.stream.shm_fd >= 0) { + lttng_ust_lock_fd_tracker(); + close_ret = close(args.stream.shm_fd); + lttng_ust_unlock_fd_tracker(); + args.stream.shm_fd = -1; + if (close_ret) + PERROR("close"); + } + if (args.stream.wakeup_fd >= 0) { + lttng_ust_lock_fd_tracker(); + close_ret = close(args.stream.wakeup_fd); + lttng_ust_unlock_fd_tracker(); + args.stream.wakeup_fd = -1; + if (close_ret) + PERROR("close"); + } break; } case LTTNG_UST_CONTEXT: