X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fustcomm.c;h=4c1fb0efb1da750a549af9e19f5382e14e6178f6;hb=61c70d3794a4e8c965bbdbdd19934374ab83a70d;hp=ada896f68f60ad1b0d077a4786c63b44f45c123d;hpb=28db08270297a0e0654ce359069954bdc6c904f1;p=lttng-ust.git diff --git a/src/common/ustcomm.c b/src/common/ustcomm.c index ada896f6..4c1fb0ef 100644 --- a/src/common/ustcomm.c +++ b/src/common/ustcomm.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: LGPL-2.1-only * - * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 EfficiOS Inc. * Copyright (C) 2011-2013 Mathieu Desnoyers */ @@ -214,7 +214,7 @@ int ustcomm_listen_unix_sock(int sock) /* * ustcomm_close_unix_sock * - * Shutdown cleanly a unix socket. + * Close unix socket. * * Handles fd tracker internally. */ @@ -235,6 +235,24 @@ int ustcomm_close_unix_sock(int sock) return ret; } +/* + * ustcomm_shutdown_unix_sock + * + * Shutdown unix socket. Keeps the file descriptor open, but shutdown + * communication. + */ +int ustcomm_shutdown_unix_sock(int sock) +{ + int ret; + + ret = shutdown(sock, SHUT_RDWR); + if (ret) { + PERROR("Socket shutdown error"); + ret = -errno; + } + return ret; +} + /* * ustcomm_recv_unix_sock * @@ -268,17 +286,13 @@ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) } while ((ret > 0 && ret < len_last) || (ret < 0 && errno == EINTR)); if (ret < 0) { - int shutret; - if (errno != EPIPE && errno != ECONNRESET && errno != ECONNREFUSED) PERROR("recvmsg"); ret = -errno; if (ret == -ECONNRESET || ret == -ECONNREFUSED) ret = -EPIPE; - shutret = shutdown(sock, SHUT_RDWR); - if (shutret) - ERR("Socket shutdown error"); + (void) ustcomm_shutdown_unix_sock(sock); } else if (ret > 0) { ret = len; } @@ -318,17 +332,13 @@ ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len) } while (ret < 0 && errno == EINTR); if (ret < 0) { - int shutret; - if (errno != EPIPE && errno != ECONNRESET) PERROR("sendmsg"); ret = -errno; if (ret == -ECONNRESET) ret = -EPIPE; - shutret = shutdown(sock, SHUT_RDWR); - if (shutret) - ERR("Socket shutdown error"); + (void) ustcomm_shutdown_unix_sock(sock); } return ret; @@ -793,7 +803,8 @@ int ustcomm_send_reg_msg(int sock, uint32_t uint16_t_alignment, uint32_t uint32_t_alignment, uint32_t uint64_t_alignment, - uint32_t long_alignment) + uint32_t long_alignment, + const char *procname) { ssize_t len; struct lttng_ust_ctl_reg_msg reg_msg; @@ -812,7 +823,8 @@ int ustcomm_send_reg_msg(int sock, reg_msg.uint64_t_alignment = uint64_t_alignment; reg_msg.long_alignment = long_alignment; reg_msg.socket_type = type; - lttng_pthread_getname_np(reg_msg.name, LTTNG_UST_ABI_PROCNAME_LEN); + memset(reg_msg.name, 0, sizeof(reg_msg.name)); + strncpy(reg_msg.name, procname, sizeof(reg_msg.name) - 1); memset(reg_msg.padding, 0, sizeof(reg_msg.padding)); len = ustcomm_send_unix_sock(sock, ®_msg, sizeof(reg_msg)); @@ -986,7 +998,7 @@ int serialize_dynamic_type(struct lttng_ust_session *session, strncpy(uf->name, field_name, LTTNG_UST_ABI_SYM_NAME_LEN); uf->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; - uf->type.atype = lttng_ust_ctl_atype_variant; + uf->type.atype = lttng_ust_ctl_atype_variant_nestable; uf->type.u.variant_nestable.nr_choices = nr_choices; strncpy(uf->type.u.variant_nestable.tag_name, tag_field_name, @@ -1715,7 +1727,7 @@ int ustcomm_register_channel(int sock, } /* - * Set socket reciving timeout. + * Set socket receiving timeout. */ int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec) {