X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Finet.cpp;h=633685799aad448f352adfac358c5214269dfa05;hb=HEAD;hp=30aa8c6134a42903f2df14cd6e0e69c103d2173a;hpb=c9e313bc594f40a86eed237dce222c0fc99c957f;p=lttng-tools.git diff --git a/src/common/sessiond-comm/inet.cpp b/src/common/sessiond-comm/inet.cpp index 30aa8c613..633685799 100644 --- a/src/common/sessiond-comm/inet.cpp +++ b/src/common/sessiond-comm/inet.cpp @@ -6,25 +6,25 @@ */ #define _LGPL_SOURCE +#include "inet.hpp" + +#include +#include +#include +#include + #include +#include #include +#include #include #include #include #include #include #include -#include -#include -#include - -#include -#include -#include - -#include "inet.hpp" -#define RECONNECT_DELAY 200 /* ms */ +#define RECONNECT_DELAY 200 /* ms */ /* * INET protocol operations. @@ -93,16 +93,14 @@ int lttcomm_bind_inet_sock(struct lttcomm_sock *sock) 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; @@ -132,8 +130,7 @@ int connect_with_timeout(struct lttcomm_sock *sock) 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 */ @@ -141,7 +138,9 @@ int connect_with_timeout(struct lttcomm_sock *sock) } 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. @@ -165,8 +164,7 @@ int connect_with_timeout(struct lttcomm_sock *sock) 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; @@ -258,7 +256,7 @@ struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) } new_sock = lttcomm_alloc_sock(sock->proto); - if (new_sock == NULL) { + if (new_sock == nullptr) { goto error; } @@ -298,7 +296,7 @@ error_close: error: free(new_sock); - return NULL; + return nullptr; } /* @@ -334,8 +332,7 @@ end: * * 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]; @@ -390,8 +387,7 @@ end: * * 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]; @@ -484,7 +480,7 @@ static unsigned long read_proc_value(const char *path) buf[size_ret] = '\0'; errno = 0; - r_val = strtol(buf, NULL, 10); + r_val = strtol(buf, nullptr, 10); if (errno != 0 || r_val < -1L) { val = 0; goto error_close; @@ -503,7 +499,7 @@ error: return val; } -void lttcomm_inet_init(void) +void lttcomm_inet_init() { unsigned long syn_retries, fin_timeout, syn_timeout, env; @@ -525,8 +521,8 @@ void lttcomm_inet_init(void) * 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);