Fix: time redefinition warnings on macOS builds
[lttng-tools.git] / src / common / sessiond-comm / inet6.c
index 52e2f8e5853d9abdb6b6bc059998fb8a92e3057c..0b0383cdd524f77c7749d93aad2c5643937009ae 100644 (file)
@@ -15,7 +15,7 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <assert.h>
 #include <limits.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <time.h>
+#include <common/compat/time.h>
 #include <poll.h>
 
 #include <common/common.h>
+#include <common/time.h>
 
 #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;
This page took 0.026099 seconds and 4 git commands to generate.