/*
* ustcomm_close_unix_sock
*
- * Shutdown cleanly a unix socket.
+ * Close unix socket.
*
* Handles fd tracker internally.
*/
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
*
} 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;
}
} 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;
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;
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));
}
/*
- * Set socket reciving timeout.
+ * Set socket receiving timeout.
*/
int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
{