projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: compat poll: add missing empty revents checks
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
jul-thread.c
diff --git
a/src/bin/lttng-sessiond/jul-thread.c
b/src/bin/lttng-sessiond/jul-thread.c
index b4a71d79849d36d739020faa6733e1916cfaca76..d6f07d8693c4fc7de0c9c6859470025e2f50c0be 100644
(file)
--- a/
src/bin/lttng-sessiond/jul-thread.c
+++ b/
src/bin/lttng-sessiond/jul-thread.c
@@
-23,6
+23,8
@@
#include <common/uri.h>
#include <common/utils.h>
#include <common/uri.h>
#include <common/utils.h>
+#include <common/compat/endian.h>
+
#include "fd-limit.h"
#include "jul-thread.h"
#include "lttng-sessiond.h"
#include "fd-limit.h"
#include "jul-thread.h"
#include "lttng-sessiond.h"
@@
-34,7
+36,8
@@
* can let the user define a custom one. However, localhost is ALWAYS the
* default listening address.
*/
* can let the user define a custom one. However, localhost is ALWAYS the
* default listening address.
*/
-static const char *default_reg_uri = "tcp://localhost";
+static const char *default_reg_uri =
+ "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS;
/*
* Update JUL application using the given socket. This is done just after
/*
* Update JUL application using the given socket. This is done just after
@@
-141,8
+144,8
@@
static struct lttcomm_sock *init_tcp_socket(void)
ret = sock->ops->bind(sock);
if (ret < 0) {
ret = sock->ops->bind(sock);
if (ret < 0) {
- WARN("An
other session daemon is using this JUL port. JUL support "
- "will be deactivated
no
t interfering with the tracing.");
+ WARN("Another session daemon is using this JUL port. JUL support "
+ "will be deactivated
to preven
t interfering with the tracing.");
goto error;
}
goto error;
}
@@
-180,12
+183,13
@@
static void destroy_tcp_socket(struct lttcomm_sock *sock)
/*
* Handle a new JUL registration using the reg socket. After that, a new JUL
* application is added to the global hash table and attach to an UST app
/*
* Handle a new JUL registration using the reg socket. After that, a new JUL
* application is added to the global hash table and attach to an UST app
- * object.
+ * object.
If r_app is not NULL, the created app is set to the pointer.
*
* Return the new FD created upon accept() on success or else a negative errno
* value.
*/
*
* Return the new FD created upon accept() on success or else a negative errno
* value.
*/
-static int handle_registration(struct lttcomm_sock *reg_sock)
+static int handle_registration(struct lttcomm_sock *reg_sock,
+ struct jul_app **r_app)
{
int ret;
pid_t pid;
{
int ret;
pid_t pid;
@@
-204,7
+208,7
@@
static int handle_registration(struct lttcomm_sock *reg_sock)
size = new_sock->ops->recvmsg(new_sock, &msg, sizeof(msg), 0);
if (size < sizeof(msg)) {
size = new_sock->ops->recvmsg(new_sock, &msg, sizeof(msg), 0);
if (size < sizeof(msg)) {
- ret = -
errno
;
+ ret = -
EINVAL
;
goto error_socket;
}
pid = be32toh(msg.pid);
goto error_socket;
}
pid = be32toh(msg.pid);
@@
-230,6
+234,10
@@
static int handle_registration(struct lttcomm_sock *reg_sock)
* app and app before JUL.
*/
* app and app before JUL.
*/
+ if (r_app) {
+ *r_app = app;
+ }
+
return new_sock->fd;
error_socket:
return new_sock->fd;
error_socket:
@@
-299,6
+307,11
@@
restart:
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
revents = LTTNG_POLL_GETEV(&events, i);
pollfd = LTTNG_POLL_GETFD(&events, i);
+ if (!revents) {
+ /* No activity for this FD (poll implementation). */
+ continue;
+ }
+
/* Thread quit pipe has been closed. Killing thread. */
ret = sessiond_check_thread_quit_pipe(pollfd, revents);
if (ret) {
/* Thread quit pipe has been closed. Killing thread. */
ret = sessiond_check_thread_quit_pipe(pollfd, revents);
if (ret) {
@@
-319,16
+332,19
@@
restart:
destroy_jul_app(pollfd);
} else if (revents & (LPOLLIN)) {
int new_fd;
destroy_jul_app(pollfd);
} else if (revents & (LPOLLIN)) {
int new_fd;
+ struct jul_app *app = NULL;
/* Pollin event of JUL app socket should NEVER happen. */
assert(pollfd == reg_sock->fd);
/* Pollin event of JUL app socket should NEVER happen. */
assert(pollfd == reg_sock->fd);
- new_fd = handle_registration(reg_sock);
+ new_fd = handle_registration(reg_sock
, &app
);
if (new_fd < 0) {
WARN("[jul-thread] JUL registration failed. Ignoring.");
/* Somehow the communication failed. Just continue. */
continue;
}
if (new_fd < 0) {
WARN("[jul-thread] JUL registration failed. Ignoring.");
/* Somehow the communication failed. Just continue. */
continue;
}
+ /* Should not have a NULL app on success. */
+ assert(app);
/* Only add poll error event to only detect shutdown. */
ret = lttng_poll_add(&events, new_fd,
/* Only add poll error event to only detect shutdown. */
ret = lttng_poll_add(&events, new_fd,
@@
-340,6
+356,9
@@
restart:
/* Update newly registered app. */
update_jul_app(new_fd);
/* Update newly registered app. */
update_jul_app(new_fd);
+
+ /* On failure, the poll will detect it and clean it up. */
+ (void) jul_send_registration_done(app);
} else {
ERR("Unknown poll events %u for sock %d", revents, pollfd);
continue;
} else {
ERR("Unknown poll events %u for sock %d", revents, pollfd);
continue;
This page took
0.025181 seconds
and
4
git commands to generate.