From a8afeb4a77269ca217cb0da0c3bb3232d60a764a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 8 Aug 2011 12:07:40 -0400 Subject: [PATCH] Don't print connect error upon failure Used in normal operation, should not print error. Signed-off-by: Mathieu Desnoyers --- liblttsessiondcomm/liblttsessiondcomm.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/liblttsessiondcomm/liblttsessiondcomm.c b/liblttsessiondcomm/liblttsessiondcomm.c index e7e420433..cffeb72c0 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.c +++ b/liblttsessiondcomm/liblttsessiondcomm.c @@ -115,11 +115,12 @@ int lttcomm_connect_unix_sock(const char *pathname) { struct sockaddr_un sun; int fd; - int ret = 1; + int ret; fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); + ret = fd; goto error; } @@ -129,14 +130,20 @@ int lttcomm_connect_unix_sock(const char *pathname) ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun)); if (ret < 0) { - perror("connect"); - goto error; + /* + * Don't print message on connect error, because connect + * is used in normal execution to detect if sessiond is + * alive. + */ + goto error_connect; } return fd; +error_connect: + close(fd); error: - return -1; + return ret; } /* -- 2.34.1