* 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 */
/*
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) {
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;
{
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");
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;
goto success;
}
+ DBG("Asynchronous connect for sock %d, performing polling with"
+ " timeout: %lums", sock->fd, timeout);
+
/*
* Perform poll loop following EINPROGRESS recommendation from
* connect(2) man page.
ret = getsockopt(sock->fd, SOL_SOCKET,
SO_ERROR, &optval, &optval_len);
if (ret) {
+ PERROR("getsockopt");
goto error;
}
if (!optval) {
connect_ret = 0;
goto success;
} else {
+ /* Get actual connect() errno from opt_val */
+ errno = optval;
goto error;
}
}
/* 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;
* 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;
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;