projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 2.5.7
[lttng-ust.git]
/
liblttng-ust-comm
/
lttng-ust-comm.c
diff --git
a/liblttng-ust-comm/lttng-ust-comm.c
b/liblttng-ust-comm/lttng-ust-comm.c
index 5321922d5278f84d544a2005fa955e2d5ad42aa9..1e9972d2461f77c617c6f67864d8fe019caa2f7b 100644
(file)
--- a/
liblttng-ust-comm/lttng-ust-comm.c
+++ b/
liblttng-ust-comm/lttng-ust-comm.c
@@
-265,7
+265,8
@@
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
{
struct msghdr msg;
struct iovec iov[1];
{
struct msghdr msg;
struct iovec iov[1];
- ssize_t ret;
+ ssize_t ret = -1;
+ size_t len_last;
memset(&msg, 0, sizeof(msg));
memset(&msg, 0, sizeof(msg));
@@
-275,8
+276,14
@@
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
msg.msg_iovlen = 1;
do {
msg.msg_iovlen = 1;
do {
+ len_last = iov[0].iov_len;
ret = recvmsg(sock, &msg, 0);
ret = recvmsg(sock, &msg, 0);
- } 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) {
int shutret;
if (ret < 0) {
int shutret;
@@
-290,7
+297,10
@@
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
shutret = shutdown(sock, SHUT_RDWR);
if (shutret)
ERR("Socket shutdown error");
shutret = shutdown(sock, SHUT_RDWR);
if (shutret)
ERR("Socket shutdown error");
+ } else if (ret > 0) {
+ ret = len;
}
}
+ /* ret = 0 means an orderly shutdown. */
return ret;
}
return ret;
}
@@
-367,6
+377,8
@@
ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
msg.msg_controllen = CMSG_LEN(sizeof_fds);
cmptr = CMSG_FIRSTHDR(&msg);
msg.msg_controllen = CMSG_LEN(sizeof_fds);
cmptr = CMSG_FIRSTHDR(&msg);
+ if (!cmptr)
+ return -EINVAL;
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
cmptr->cmsg_len = CMSG_LEN(sizeof_fds);
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
cmptr->cmsg_len = CMSG_LEN(sizeof_fds);
@@
-380,7
+392,7
@@
ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
msg.msg_iovlen = 1;
do {
msg.msg_iovlen = 1;
do {
- ret = sendmsg(sock, &msg,
0
);
+ ret = sendmsg(sock, &msg,
MSG_NOSIGNAL
);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
/*
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
/*
@@
-956,6
+968,8
@@
int ustcomm_register_event(int sock,
if (len < 0) {
return len;
}
if (len < 0) {
return len;
}
+ } else {
+ free(fields);
}
if (model_emf_uri_len) {
}
if (model_emf_uri_len) {
@@
-1062,6
+1076,8
@@
int ustcomm_register_channel(int sock,
if (len < 0) {
return len;
}
if (len < 0) {
return len;
}
+ } else {
+ free(fields);
}
len = ustcomm_recv_unix_sock(sock, &reply, sizeof(reply));
}
len = ustcomm_recv_unix_sock(sock, &reply, sizeof(reply));
This page took
0.029796 seconds
and
4
git commands to generate.