*/
#define _LGPL_SOURCE
+#include "inet.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/time.hpp>
+#include <common/time.hpp>
+
#include <algorithm>
+#include <fcntl.h>
#include <limits.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <common/compat/time.hpp>
-#include <poll.h>
-
-#include <common/common.hpp>
-#include <common/time.hpp>
-#include <common/compat/errno.hpp>
-
-#include "inet.hpp"
-#define RECONNECT_DELAY 200 /* ms */
+#define RECONNECT_DELAY 200 /* ms */
/*
* INET protocol operations.
return bind(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
}
-static
-int connect_no_timeout(struct lttcomm_sock *sock)
+static int connect_no_timeout(struct lttcomm_sock *sock)
{
struct sockaddr_in sockaddr = sock->sockaddr.addr.sin;
return connect(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
}
-static
-int connect_with_timeout(struct lttcomm_sock *sock)
+static int connect_with_timeout(struct lttcomm_sock *sock)
{
unsigned long timeout = lttcomm_get_network_timeout();
int ret, flags, connect_ret;
sockaddr = sock->sockaddr.addr.sin;
connect_ret = connect(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
- if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK &&
- errno != EINPROGRESS) {
+ if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINPROGRESS) {
goto error;
} else if (!connect_ret) {
/* Connect succeeded */
}
DBG("Asynchronous connect for sock %d, performing polling with"
- " timeout: %lums", sock->fd, timeout);
+ " timeout: %lums",
+ sock->fd,
+ timeout);
/*
* Perform poll loop following EINPROGRESS recommendation from
* connect(2) man page.
goto error;
}
/* got something */
- ret = getsockopt(sock->fd, SOL_SOCKET,
- SO_ERROR, &optval, &optval_len);
+ ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &optval, &optval_len);
if (ret) {
PERROR("getsockopt");
goto error;
*
* Return the size of received data.
*/
-ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
- size_t len, int flags)
+ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
*
* Return the size of sent data.
*/
-ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, const void *buf,
- size_t len, int flags)
+ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
* Get the maximum between the two possible timeout value and use that to
* get the maximum with the default timeout.
*/
- lttcomm_inet_tcp_timeout = std::max(std::max(syn_timeout, fin_timeout),
- lttcomm_inet_tcp_timeout);
+ lttcomm_inet_tcp_timeout =
+ std::max(std::max(syn_timeout, fin_timeout), lttcomm_inet_tcp_timeout);
end:
DBG("TCP inet operation timeout set to %lu sec", lttcomm_inet_tcp_timeout);