projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move LTTNG_RUNDIR declaration to lttng/lttng-sessiond-comm.h
[lttng-tools.git]
/
liblttsessiondcomm
/
liblttsessiondcomm.c
diff --git
a/liblttsessiondcomm/liblttsessiondcomm.c
b/liblttsessiondcomm/liblttsessiondcomm.c
index e7e4204339d61dc0b1daa97cdadd3b1c6fd8033c..cecd89d6a5815fc7ee1e472821474afc4785dc39 100644
(file)
--- a/
liblttsessiondcomm/liblttsessiondcomm.c
+++ b/
liblttsessiondcomm/liblttsessiondcomm.c
@@
-28,7
+28,7
@@
#include <unistd.h>
#include <assert.h>
#include <unistd.h>
#include <assert.h>
-#include
"liblttsessiondcomm.h"
+#include
<lttng/lttng-sessiond-comm.h>
/*
* Human readable error message.
/*
* Human readable error message.
@@
-115,28
+115,36
@@
int lttcomm_connect_unix_sock(const char *pathname)
{
struct sockaddr_un sun;
int fd;
{
struct sockaddr_un sun;
int fd;
- int ret
= 1
;
+ int ret;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
+ ret = fd;
goto error;
}
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
goto error;
}
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
+ sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun));
if (ret < 0) {
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;
}
return fd;
+error_connect:
+ close(fd);
error:
error:
- return
-1
;
+ return
ret
;
}
/*
}
/*
@@
-184,7
+192,8
@@
int lttcomm_create_unix_sock(const char *pathname)
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
- strncpy(sun.sun_path, pathname, strlen(pathname));
+ strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
+ sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
/* Unlink the old file if present */
(void) unlink(pathname);
/* Unlink the old file if present */
(void) unlink(pathname);
This page took
0.025877 seconds
and
4
git commands to generate.