X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Finet6.c;h=0b0383cdd524f77c7749d93aad2c5643937009ae;hp=52e2f8e5853d9abdb6b6bc059998fb8a92e3057c;hb=395d6b02dda3db1acd08936f49c1dc8efc48e613;hpb=a655f4cf59f557aef3f0a975988d87bdd3b199fd diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c index 52e2f8e58..0b0383cdd 100644 --- a/src/common/sessiond-comm/inet6.c +++ b/src/common/sessiond-comm/inet6.c @@ -15,7 +15,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -26,15 +26,14 @@ #include #include #include -#include +#include #include #include +#include #include "inet6.h" -#define MSEC_PER_SEC 1000 -#define NSEC_PER_MSEC 1000000 #define RECONNECT_DELAY 200 /* ms */ /* @@ -57,6 +56,7 @@ LTTNG_HIDDEN int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type, int proto) { int val = 1, ret; + unsigned long timeout; /* Create server socket */ if ((sock->fd = socket(PF_INET6, type, proto)) < 0) { @@ -74,6 +74,17 @@ int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type, int proto) PERROR("setsockopt inet6"); goto error; } + timeout = lttcomm_get_network_timeout(); + if (timeout) { + ret = lttcomm_setsockopt_rcv_timeout(sock->fd, timeout); + if (ret) { + goto error; + } + ret = lttcomm_setsockopt_snd_timeout(sock->fd, timeout); + if (ret) { + goto error; + } + } return 0; @@ -89,7 +100,7 @@ int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock) { int ret; - ret = bind(sock->fd, &sock->sockaddr.addr.sin6, + ret = bind(sock->fd, (const struct sockaddr *) &sock->sockaddr.addr.sin6, sizeof(sock->sockaddr.addr.sin6)); if (ret < 0) { PERROR("bind inet6"); @@ -145,7 +156,7 @@ int connect_with_timeout(struct lttcomm_sock *sock) return -1; } - ret = clock_gettime(CLOCK_MONOTONIC, &orig_time); + ret = lttng_clock_gettime(CLOCK_MONOTONIC, &orig_time); if (ret == -1) { PERROR("clock_gettime"); return -1; @@ -199,7 +210,7 @@ int connect_with_timeout(struct lttcomm_sock *sock) } } /* ret == 0: timeout */ - ret = clock_gettime(CLOCK_MONOTONIC, &cur_time); + ret = lttng_clock_gettime(CLOCK_MONOTONIC, &cur_time); if (ret == -1) { PERROR("clock_gettime"); connect_ret = ret; @@ -374,7 +385,7 @@ ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, * Return the size of sent data. */ LTTNG_HIDDEN -ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, +ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags) { struct msghdr msg; @@ -383,7 +394,7 @@ ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, memset(&msg, 0, sizeof(msg)); - iov[0].iov_base = buf; + iov[0].iov_base = (void *) buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1;