X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ffd-handle.c;h=b2b7efd2369dae22ba3c62d4c32fa5e071713408;hb=3afa94aeca5a0daae40fd7b6cc96b7e4c150c7d8;hp=a9c7be4a938ab86aa44d3c6316c3ccd8a04e6537;hpb=dd1bac00c933616842aaf51ad4c4240ccee98838;p=lttng-tools.git diff --git a/src/common/fd-handle.c b/src/common/fd-handle.c index a9c7be4a9..b2b7efd23 100644 --- a/src/common/fd-handle.c +++ b/src/common/fd-handle.c @@ -21,7 +21,7 @@ static void fd_handle_release(struct urcu_ref *ref) int ret; struct fd_handle *handle = container_of(ref, struct fd_handle, ref); - assert(handle->fd >= 0); + LTTNG_ASSERT(handle->fd >= 0); ret = close(handle->fd); if (ret == -1) { PERROR("Failed to close file descriptor of fd_handle upon release: fd = %d", @@ -31,7 +31,6 @@ static void fd_handle_release(struct urcu_ref *ref) free(handle); } -LTTNG_HIDDEN struct fd_handle *fd_handle_create(int fd) { struct fd_handle *handle = NULL; @@ -55,28 +54,30 @@ end: return handle; } -LTTNG_HIDDEN void fd_handle_get(struct fd_handle *handle) { - assert(handle); + if (!handle) { + return; + } + urcu_ref_get(&handle->ref); } -LTTNG_HIDDEN void fd_handle_put(struct fd_handle *handle) { - assert(handle); + if (!handle) { + return; + } + urcu_ref_put(&handle->ref, fd_handle_release); } -LTTNG_HIDDEN int fd_handle_get_fd(struct fd_handle *handle) { - assert(handle); + LTTNG_ASSERT(handle); return handle->fd; } -LTTNG_HIDDEN struct fd_handle *fd_handle_copy(const struct fd_handle *handle) { struct fd_handle *new_handle = NULL;