X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Finet.c;h=f9ea17dbf975b246448e463b69ff64978745c9bc;hb=76f66f6356f4ad6bebc7b69b3856d2529c102106;hp=3cf8f5d3f5b4f89be36307929dee051590dafb98;hpb=6e7423591c5edde632d79ff52ba449d99da8eb14;p=lttng-tools.git diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index 3cf8f5d3f..f9ea17dbf 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -47,9 +47,10 @@ static const struct lttcomm_proto_ops inet_ops = { /* * Creates an PF_INET socket. */ +__attribute__((visibility("hidden"))) int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type, int proto) { - int val, ret; + int val = 1, ret; /* Create server socket */ if ((sock->fd = socket(PF_INET, type, proto)) < 0) { @@ -77,6 +78,7 @@ error: /* * Bind socket and return. */ +__attribute__((visibility("hidden"))) int lttcomm_bind_inet_sock(struct lttcomm_sock *sock) { int ret; @@ -93,6 +95,7 @@ int lttcomm_bind_inet_sock(struct lttcomm_sock *sock) /* * Connect PF_INET socket. */ +__attribute__((visibility("hidden"))) int lttcomm_connect_inet_sock(struct lttcomm_sock *sock) { int ret, closeret; @@ -122,10 +125,11 @@ error_connect: * Do an accept(2) on the sock and return the new lttcomm socket. The socket * MUST be bind(2) before. */ +__attribute__((visibility("hidden"))) struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) { int new_fd; - socklen_t len = 0; + socklen_t len; struct lttcomm_sock *new_sock; if (sock->proto == LTTCOMM_SOCK_UDP) { @@ -136,11 +140,13 @@ struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) goto end; } - new_sock = lttcomm_alloc_sock(LTTCOMM_INET, sock->proto); + new_sock = lttcomm_alloc_sock(sock->proto); if (new_sock == NULL) { goto error; } + len = sizeof(new_sock->sockaddr.addr.sin); + /* Blocking call */ new_fd = accept(sock->fd, (struct sockaddr *) &new_sock->sockaddr.addr.sin, &len); @@ -150,6 +156,7 @@ struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) } new_sock->fd = new_fd; + new_sock->ops = &inet_ops; end: return new_sock; @@ -162,6 +169,7 @@ error: /* * Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN. */ +__attribute__((visibility("hidden"))) int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog) { int ret; @@ -192,6 +200,7 @@ end: * * Return the size of received data. */ +__attribute__((visibility("hidden"))) ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags) { @@ -228,6 +237,7 @@ ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, * * Return the size of sent data. */ +__attribute__((visibility("hidden"))) ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags) { @@ -270,11 +280,12 @@ ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf, /* * Shutdown cleanly and close. */ +__attribute__((visibility("hidden"))) int lttcomm_close_inet_sock(struct lttcomm_sock *sock) { int ret; - /* Don't try to close an invalid mark socket */ + /* Don't try to close an invalid marked socket */ if (sock->fd == -1) { return 0; }