projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: poll: show the correct number of fds
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
agent-thread.c
diff --git
a/src/bin/lttng-sessiond/agent-thread.c
b/src/bin/lttng-sessiond/agent-thread.c
index da0171ba0afadf7ff883b7545e823b3dab346c48..5f4815165fed49c113a8e9ce875c5a374890b7c6 100644
(file)
--- a/
src/bin/lttng-sessiond/agent-thread.c
+++ b/
src/bin/lttng-sessiond/agent-thread.c
@@
-16,6
+16,7
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <common/common.h>
#include <assert.h>
#include <common/common.h>
@@
-46,7
+47,7
@@
static const char *default_reg_uri =
* This is a quite heavy call in terms of locking since the session list lock
* AND session lock are acquired.
*/
* This is a quite heavy call in terms of locking since the session list lock
* AND session lock are acquired.
*/
-static void update_agent_app(
int sock
)
+static void update_agent_app(
struct agent_app *app
)
{
struct ltt_session *session, *stmp;
struct ltt_session_list *list;
{
struct ltt_session *session, *stmp;
struct ltt_session_list *list;
@@
-58,7
+59,14
@@
static void update_agent_app(int sock)
cds_list_for_each_entry_safe(session, stmp, &list->head, list) {
session_lock(session);
if (session->ust_session) {
cds_list_for_each_entry_safe(session, stmp, &list->head, list) {
session_lock(session);
if (session->ust_session) {
- agent_update(&session->ust_session->agent, sock);
+ struct agent *agt;
+
+ rcu_read_lock();
+ agt = trace_ust_find_agent(session->ust_session, app->domain);
+ if (agt) {
+ agent_update(agt, app->sock->fd);
+ }
+ rcu_read_unlock();
}
session_unlock(session);
}
}
session_unlock(session);
}
@@
-193,7
+201,9
@@
static int handle_registration(struct lttcomm_sock *reg_sock,
{
int ret;
pid_t pid;
{
int ret;
pid_t pid;
+ uint32_t major_version, minor_version;
ssize_t size;
ssize_t size;
+ enum lttng_domain_type domain;
struct agent_app *app;
struct agent_register_msg msg;
struct lttcomm_sock *new_sock;
struct agent_app *app;
struct agent_register_msg msg;
struct lttcomm_sock *new_sock;
@@
-208,15
+218,28
@@
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;
}
goto error_socket;
}
+ domain = be32toh(msg.domain);
pid = be32toh(msg.pid);
pid = be32toh(msg.pid);
+ major_version = be32toh(msg.major_version);
+ minor_version = be32toh(msg.minor_version);
- DBG2("[agent-thread] New registration for pid %d on socket %d", pid,
- new_sock->fd);
+ /* Test communication protocol version of the registring agent. */
+ if (major_version != AGENT_MAJOR_VERSION) {
+ ret = -EINVAL;
+ goto error_socket;
+ }
+ if (minor_version != AGENT_MINOR_VERSION) {
+ ret = -EINVAL;
+ goto error_socket;
+ }
- app = agent_create_app(pid, new_sock);
+ DBG2("[agent-thread] New registration for pid %d domain %d on socket %d",
+ pid, domain, new_sock->fd);
+
+ app = agent_create_app(pid, domain, new_sock);
if (!app) {
ret = -ENOMEM;
goto error_socket;
if (!app) {
ret = -ENOMEM;
goto error_socket;
@@
-284,12
+307,14
@@
void *agent_thread_manage_registration(void *data)
}
while (1) {
}
while (1) {
- DBG3("[agent-thread] Manage agent polling
on %d fds
",
+ DBG3("[agent-thread] Manage agent polling",
LTTNG_POLL_GETNB(&events));
/* Inifinite blocking call, waiting for transmission */
restart:
ret = lttng_poll_wait(&events, -1);
LTTNG_POLL_GETNB(&events));
/* Inifinite blocking call, waiting for transmission */
restart:
ret = lttng_poll_wait(&events, -1);
+ DBG3("[agent-thread] Manage agent return from poll on %d fds",
+ LTTNG_POLL_GETNB(&events));
if (ret < 0) {
/*
* Restart interrupted system call.
if (ret < 0) {
/*
* Restart interrupted system call.
@@
-307,6
+332,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) {
@@
-350,7
+380,7
@@
restart:
}
/* Update newly registered app. */
}
/* Update newly registered app. */
- update_agent_app(
new_fd
);
+ update_agent_app(
app
);
/* On failure, the poll will detect it and clean it up. */
(void) agent_send_registration_done(app);
/* On failure, the poll will detect it and clean it up. */
(void) agent_send_registration_done(app);
This page took
0.025067 seconds
and
4
git commands to generate.