projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Relayd add_stream command handle tracefile rotation
[lttng-tools.git]
/
src
/
common
/
sessiond-comm
/
inet6.c
diff --git
a/src/common/sessiond-comm/inet6.c
b/src/common/sessiond-comm/inet6.c
index ac6d0988afb85cce87f8f31e02d0fced5a4f68e3..e9558d948652e7a7c2930645bf98c9238d66c860 100644
(file)
--- a/
src/common/sessiond-comm/inet6.c
+++ b/
src/common/sessiond-comm/inet6.c
@@
-26,8
+26,7
@@
#include <unistd.h>
#include <errno.h>
#include <unistd.h>
#include <errno.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <common/common.h>
#include "inet6.h"
#include "inet6.h"
@@
-47,12
+46,13
@@
static const struct lttcomm_proto_ops inet6_ops = {
/*
* Creates an PF_INET socket.
*/
/*
* Creates an PF_INET socket.
*/
+LTTNG_HIDDEN
int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type, int proto)
{
int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type, int proto)
{
- int val, ret;
+ int val
= 1
, ret;
/* Create server socket */
/* Create server socket */
- if ((sock->fd = socket(PF_INET, type, proto)) < 0) {
+ if ((sock->fd = socket(PF_INET
6
, type, proto)) < 0) {
PERROR("socket inet6");
goto error;
}
PERROR("socket inet6");
goto error;
}
@@
-77,6
+77,7
@@
error:
/*
* Bind socket and return.
*/
/*
* Bind socket and return.
*/
+LTTNG_HIDDEN
int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock)
{
int ret;
int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock)
{
int ret;
@@
-93,6
+94,7
@@
int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock)
/*
* Connect PF_INET socket.
*/
/*
* Connect PF_INET socket.
*/
+LTTNG_HIDDEN
int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock)
{
int ret, closeret;
int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock)
{
int ret, closeret;
@@
-122,10
+124,11
@@
error_connect:
* Do an accept(2) on the sock and return the new lttcomm socket. The socket
* MUST be bind(2) before.
*/
* Do an accept(2) on the sock and return the new lttcomm socket. The socket
* MUST be bind(2) before.
*/
+LTTNG_HIDDEN
struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock)
{
int new_fd;
struct lttcomm_sock *lttcomm_accept_inet6_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) {
struct lttcomm_sock *new_sock;
if (sock->proto == LTTCOMM_SOCK_UDP) {
@@
-136,11
+139,13
@@
struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock)
goto end;
}
goto end;
}
- new_sock = lttcomm_alloc_sock(
LTTCOMM_INET,
sock->proto);
+ new_sock = lttcomm_alloc_sock(sock->proto);
if (new_sock == NULL) {
goto error;
}
if (new_sock == NULL) {
goto error;
}
+ len = sizeof(new_sock->sockaddr.addr.sin6);
+
/* Blocking call */
new_fd = accept(sock->fd,
(struct sockaddr *) &new_sock->sockaddr.addr.sin6, &len);
/* Blocking call */
new_fd = accept(sock->fd,
(struct sockaddr *) &new_sock->sockaddr.addr.sin6, &len);
@@
-150,6
+155,7
@@
struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock)
}
new_sock->fd = new_fd;
}
new_sock->fd = new_fd;
+ new_sock->ops = &inet6_ops;
end:
return new_sock;
end:
return new_sock;
@@
-162,6
+168,7
@@
error:
/*
* Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN.
*/
/*
* Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN.
*/
+LTTNG_HIDDEN
int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog)
{
int ret;
int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog)
{
int ret;
@@
-192,12
+199,14
@@
end:
*
* Return the size of received data.
*/
*
* Return the size of received data.
*/
+LTTNG_HIDDEN
ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
ssize_t ret = -1;
ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
ssize_t ret = -1;
+ size_t len_last;
memset(&msg, 0, sizeof(msg));
memset(&msg, 0, sizeof(msg));
@@
-209,16
+218,21
@@
ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
msg.msg_name = (struct sockaddr *) &sock->sockaddr.addr.sin6;
msg.msg_namelen = sizeof(sock->sockaddr.addr.sin6);
msg.msg_name = (struct sockaddr *) &sock->sockaddr.addr.sin6;
msg.msg_namelen = sizeof(sock->sockaddr.addr.sin6);
- if (flags == 0) {
- flags = MSG_WAITALL;
- }
-
do {
do {
+ len_last = iov[0].iov_len;
ret = recvmsg(sock->fd, &msg, flags);
ret = recvmsg(sock->fd, &msg, flags);
- } while (ret < 0 && errno == EINTR);
+ if (ret > 0) {
+ iov[0].iov_base += ret;
+ iov[0].iov_len -= ret;
+ assert(ret <= len_last);
+ }
+ } while ((ret > 0 && ret < len_last) || (ret < 0 && errno == EINTR));
if (ret < 0) {
if (ret < 0) {
- PERROR("recvmsg inet6");
+ PERROR("recvmsg inet");
+ } else if (ret > 0) {
+ ret = len;
}
}
+ /* Else ret = 0 meaning an orderly shutdown. */
return ret;
}
return ret;
}
@@
-228,6
+242,7
@@
ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
*
* Return the size of sent data.
*/
*
* Return the size of sent data.
*/
+LTTNG_HIDDEN
ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
@@
-270,11
+285,12
@@
ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
/*
* Shutdown cleanly and close.
*/
/*
* Shutdown cleanly and close.
*/
+LTTNG_HIDDEN
int lttcomm_close_inet6_sock(struct lttcomm_sock *sock)
{
int ret;
int lttcomm_close_inet6_sock(struct lttcomm_sock *sock)
{
int ret;
- /* Don't try to close an invalid mark socket */
+ /* Don't try to close an invalid mark
ed
socket */
if (sock->fd == -1) {
return 0;
}
if (sock->fd == -1) {
return 0;
}
This page took
0.029525 seconds
and
4
git commands to generate.