X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust-comm%2Flttng-ust-comm.c;h=b4fe11b0b0a91d1ce9916e4e19c5e1c57e58208a;hb=b020e504e028f60a8721d59c3556a7f65bf6b790;hp=2903d57574b68d3d11f839604a324fb81079bde2;hpb=4318ae1be57eb7983ab4857a7a8eeb4a030a8216;p=lttng-ust.git diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 2903d575..b4fe11b0 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -1,19 +1,20 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 - Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; only version 2 - * of the License. - * - * This program is distributed in the hope that it will be useful, + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; only + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define _GNU_SOURCE @@ -29,7 +30,7 @@ #include #include -#include +#include /* * Human readable error message. @@ -354,16 +355,15 @@ int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum) len = ustcomm_send_unix_sock(sock, lum, sizeof(*lum)); switch (len) { case sizeof(*lum): - printf("message successfully sent\n"); break; case -1: if (errno == ECONNRESET) { - printf("remote end closed connection\n"); + fprintf(stderr, "remote end closed connection\n"); return 0; } return -1; default: - printf("incorrect message size: %zd\n", len); + fprintf(stderr, "incorrect message size: %zd\n", len); return -1; } return 0; @@ -378,33 +378,35 @@ int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur, len = ustcomm_recv_unix_sock(sock, lur, sizeof(*lur)); switch (len) { case 0: /* orderly shutdown */ - printf("Application has performed an orderly shutdown\n"); return -EINVAL; case sizeof(*lur): - printf("result message received\n"); if (lur->handle != expected_handle) { - printf("Unexpected result message handle\n"); + fprintf(stderr, "Unexpected result message handle\n"); return -EINVAL; } if (lur->cmd != expected_cmd) { - printf("Unexpected result message command\n"); + fprintf(stderr, "Unexpected result message command\n"); return -EINVAL; } if (lur->ret_code != USTCOMM_OK) { - printf("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; case -1: if (errno == ECONNRESET) { - printf("remote end closed connection\n"); + fprintf(stderr, "remote end closed connection\n"); return -EINVAL; } return -1; default: - printf("incorrect message size: %zd\n", len); + fprintf(stderr, "incorrect message size: %zd\n", len); return len > 0 ? -1 : len; } } @@ -452,23 +454,22 @@ int ustcomm_recv_fd(int sock) msg.msg_control = recv_fd; msg.msg_controllen = sizeof(recv_fd); - printf("Waiting to receive fd\n"); if ((ret = recvmsg(sock, &msg, 0)) < 0) { perror("recvmsg"); goto end; } if (ret != sizeof(data_fd)) { - printf("Received %d bytes, expected %ld", ret, sizeof(data_fd)); + fprintf(stderr, "Received %d bytes, expected %zd", ret, sizeof(data_fd)); goto end; } cmsg = CMSG_FIRSTHDR(&msg); if (!cmsg) { - printf("Invalid control message header\n"); + fprintf(stderr, "Invalid control message header\n"); ret = -1; goto end; } if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { - printf("Didn't received any fd\n"); + fprintf(stderr, "Didn't received any fd\n"); ret = -1; goto end; } @@ -476,7 +477,10 @@ int ustcomm_recv_fd(int sock) for (i = 0; i < sizeof(int); i++) tmp.vc[i] = CMSG_DATA(cmsg)[i]; ret = tmp.vi; - printf("received fd %d\n", ret); + /* + * Useful for fd leak debug. + * fprintf(stderr, "received fd %d\n", ret); + */ end: return ret; }