*/
#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <limits.h>
#include <stdio.h>
return new_fd;
}
+LTTNG_HIDDEN
+int lttcomm_create_anon_unix_socketpair(int *fds)
+{
+ if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds) < 0) {
+ PERROR("socketpair");
+ return -1;
+ }
+ return 0;
+}
+
/*
* Creates a AF_UNIX local socket using pathname bind the socket upon creation
* and return the fd.
do {
len_last = iov[0].iov_len;
- ret = recvmsg(sock, &msg, 0);
+ ret = recvmsg(sock, &msg, MSG_NOSIGNAL);
if (ret > 0) {
iov[0].iov_base += ret;
iov[0].iov_len -= 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);
#endif /* __linux__ */
do {
+ len_last = iov[0].iov_len;
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;
+ } else if (ret > 0) {
+ ret = len;
}
+ /* Else ret = 0 meaning an orderly shutdown. */
#ifdef __linux__
if (msg.msg_flags & MSG_CTRUNC) {