projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: recv creds comm should handle partial receive
[lttng-tools.git]
/
src
/
common
/
sessiond-comm
/
unix.c
diff --git
a/src/common/sessiond-comm/unix.c
b/src/common/sessiond-comm/unix.c
index 0d7c95a7637638f066b28f0c2dbe14dc2bbd393d..2c87b82c451f87de02fb5db074cb24a32c752696 100644
(file)
--- a/
src/common/sessiond-comm/unix.c
+++ b/
src/common/sessiond-comm/unix.c
@@
-435,6
+435,7
@@
ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
struct msghdr msg;
struct iovec iov[1];
ssize_t ret;
struct msghdr msg;
struct iovec iov[1];
ssize_t ret;
+ size_t len_last;
#ifdef __linux__
struct cmsghdr *cmptr;
size_t sizeof_cred = sizeof(lttng_sock_cred);
#ifdef __linux__
struct cmsghdr *cmptr;
size_t sizeof_cred = sizeof(lttng_sock_cred);
@@
-461,12
+462,21
@@
ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
#endif /* __linux__ */
do {
#endif /* __linux__ */
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) {
PERROR("recvmsg fds");
goto end;
if (ret < 0) {
PERROR("recvmsg fds");
goto end;
+ } else if (ret > 0) {
+ ret = len;
}
}
+ /* Else ret = 0 meaning an orderly shutdown. */
#ifdef __linux__
if (msg.msg_flags & MSG_CTRUNC) {
#ifdef __linux__
if (msg.msg_flags & MSG_CTRUNC) {
This page took
0.025063 seconds
and
4
git commands to generate.