projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove inappropriate \n from easy-ust sample
[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 f013c2cd7316e459ec21fd100c4d12d7ff92a025..2332dbf1a383d2b2b6e1500fb604039e53ab72e9 100644
(file)
--- a/
liblttng-ust-comm/lttng-ust-comm.c
+++ b/
liblttng-ust-comm/lttng-ust-comm.c
@@
-30,7
+30,7
@@
#include <assert.h>
#include <errno.h>
#include <assert.h>
#include <errno.h>
-#include <
lttng/
ust-comm.h>
+#include <ust-comm.h>
/*
* Human readable error message.
/*
* Human readable error message.
@@
-237,17
+237,21
@@
int ustcomm_listen_unix_sock(int sock)
*/
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
{
*/
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
{
- struct msghdr msg
= { 0 }
;
+ struct msghdr msg;
struct iovec iov[1];
ssize_t ret = -1;
struct iovec iov[1];
ssize_t ret = -1;
+ memset(&msg, 0, sizeof(msg));
+
iov[0].iov_base = buf;
iov[0].iov_len = len;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
iov[0].iov_base = buf;
iov[0].iov_len = len;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
- ret = recvmsg(sock, &msg, 0);
- if (ret < 0) {
+ do {
+ ret = recvmsg(sock, &msg, 0);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0 && errno != EPIPE) {
perror("recvmsg");
}
perror("recvmsg");
}
@@
-262,10
+266,12
@@
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
*/
ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len)
{
*/
ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len)
{
- struct msghdr msg
= { 0 }
;
+ struct msghdr msg;
struct iovec iov[1];
ssize_t ret = -1;
struct iovec iov[1];
ssize_t ret = -1;
+ memset(&msg, 0, sizeof(msg));
+
iov[0].iov_base = buf;
iov[0].iov_len = len;
msg.msg_iov = iov;
iov[0].iov_base = buf;
iov[0].iov_len = len;
msg.msg_iov = iov;
@@
-278,8
+284,10
@@
ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len)
* by ignoring SIGPIPE, but we don't have this luxury on the
* libust side.
*/
* by ignoring SIGPIPE, but we don't have this luxury on the
* libust side.
*/
- ret = sendmsg(sock, &msg, MSG_NOSIGNAL);
- if (ret < 0) {
+ do {
+ ret = sendmsg(sock, &msg, MSG_NOSIGNAL);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0 && errno != EPIPE) {
perror("sendmsg");
}
perror("sendmsg");
}
@@
-295,10
+303,9
@@
int ustcomm_close_unix_sock(int sock)
{
int ret;
{
int ret;
- /* Shutdown receptions and transmissions */
- ret = shutdown(sock, SHUT_RDWR);
+ ret = close(sock);
if (ret < 0) {
if (ret < 0) {
- perror("
shutdown
");
+ perror("
close
");
}
return ret;
}
return ret;
@@
-311,13
+318,15
@@
int ustcomm_close_unix_sock(int sock)
*/
ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, size_t nb_fd, size_t len)
{
*/
ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, size_t nb_fd, size_t len)
{
- struct msghdr msg
= { 0 }
;
+ struct msghdr msg;
struct cmsghdr *cmptr;
struct iovec iov[1];
ssize_t ret = -1;
unsigned int sizeof_fds = nb_fd * sizeof(int);
char tmp[CMSG_SPACE(sizeof_fds)];
struct cmsghdr *cmptr;
struct iovec iov[1];
ssize_t ret = -1;
unsigned int sizeof_fds = nb_fd * sizeof(int);
char tmp[CMSG_SPACE(sizeof_fds)];
+ memset(&msg, 0, sizeof(msg));
+
/*
* Note: the consumerd receiver only supports receiving one FD per
* message.
/*
* Note: the consumerd receiver only supports receiving one FD per
* message.
@@
-340,8
+349,10
@@
ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, size_t nb_fd,
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
- ret = sendmsg(sock, &msg, 0);
- if (ret < 0) {
+ do {
+ ret = sendmsg(sock, &msg, MSG_NOSIGNAL);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0 && errno != EPIPE) {
perror("sendmsg");
}
perror("sendmsg");
}
@@
-390,8
+401,12
@@
int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
return -EINVAL;
}
if (lur->ret_code != USTCOMM_OK) {
return -EINVAL;
}
if (lur->ret_code != USTCOMM_OK) {
- fprintf(stderr, "remote operation failed with code %d.\n",
- lur->ret_code);
+ /*
+ * Some errors are normal.. we should put this
+ * in a debug level message...
+ * fprintf(stderr, "remote operation failed with code %d.\n",
+ * lur->ret_code);
+ */
return lur->ret_code;
}
return 0;
return lur->ret_code;
}
return 0;
@@
-435,13
+450,15
@@
int ustcomm_recv_fd(int sock)
int data_fd;
struct cmsghdr *cmsg;
char recv_fd[CMSG_SPACE(sizeof(int))];
int data_fd;
struct cmsghdr *cmsg;
char recv_fd[CMSG_SPACE(sizeof(int))];
- struct msghdr msg
= { 0 }
;
+ struct msghdr msg;
union {
unsigned char vc[4];
int vi;
} tmp;
int i;
union {
unsigned char vc[4];
int vi;
} tmp;
int i;
+ memset(&msg, 0, sizeof(msg));
+
/* Prepare to receive the structures */
iov[0].iov_base = &data_fd;
iov[0].iov_len = sizeof(data_fd);
/* Prepare to receive the structures */
iov[0].iov_base = &data_fd;
iov[0].iov_len = sizeof(data_fd);
@@
-450,12
+467,17
@@
int ustcomm_recv_fd(int sock)
msg.msg_control = recv_fd;
msg.msg_controllen = sizeof(recv_fd);
msg.msg_control = recv_fd;
msg.msg_controllen = sizeof(recv_fd);
- if ((ret = recvmsg(sock, &msg, 0)) < 0) {
- perror("recvmsg");
+ do {
+ ret = recvmsg(sock, &msg, 0);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0) {
+ if (errno != EPIPE) {
+ perror("recvmsg");
+ }
goto end;
}
if (ret != sizeof(data_fd)) {
goto end;
}
if (ret != sizeof(data_fd)) {
- fprintf(stderr, "Received %d bytes, expected %
l
d", ret, sizeof(data_fd));
+ fprintf(stderr, "Received %d bytes, expected %
z
d", ret, sizeof(data_fd));
goto end;
}
cmsg = CMSG_FIRSTHDR(&msg);
goto end;
}
cmsg = CMSG_FIRSTHDR(&msg);
@@
-473,7
+495,10
@@
int ustcomm_recv_fd(int sock)
for (i = 0; i < sizeof(int); i++)
tmp.vc[i] = CMSG_DATA(cmsg)[i];
ret = tmp.vi;
for (i = 0; i < sizeof(int); i++)
tmp.vc[i] = CMSG_DATA(cmsg)[i];
ret = tmp.vi;
- fprintf(stderr, "received fd %d\n", ret);
+ /*
+ * Useful for fd leak debug.
+ * fprintf(stderr, "received fd %d\n", ret);
+ */
end:
return ret;
}
end:
return ret;
}
This page took
0.025018 seconds
and
4
git commands to generate.