projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: sessiond: sessiond and agent deadlock on destroy
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
agent.c
diff --git
a/src/bin/lttng-sessiond/agent.c
b/src/bin/lttng-sessiond/agent.c
index ced0f85cf018c93d5ad1ac9a79a7e6c788ab136c..0bce01b44567d9d49c31e3e40788e0c47491b66f 100644
(file)
--- a/
src/bin/lttng-sessiond/agent.c
+++ b/
src/bin/lttng-sessiond/agent.c
@@
-29,7
+29,7
@@
#include "agent.h"
#include "ust-app.h"
#include "utils.h"
#include "agent.h"
#include "ust-app.h"
#include "utils.h"
-#include "error.h"
+#include "
common/
error.h"
#define AGENT_RET_CODE_INDEX(code) (code - AGENT_RET_CODE_SUCCESS)
#define AGENT_RET_CODE_INDEX(code) (code - AGENT_RET_CODE_SUCCESS)
@@
-143,11
+143,18
@@
static int ht_match_event(struct cds_lfht_node *node,
}
/* Filter expression */
}
/* Filter expression */
- if (
strncmp(event->filter_expression, key->filter_expression,
- strlen(event->filter_expression)) != 0) {
+ if (
!!event->filter_expression != !!key->filter_expression) {
+ /* One has a filter expression, the other does not */
goto no_match;
}
goto no_match;
}
+ if (event->filter_expression) {
+ if (strncmp(event->filter_expression, key->filter_expression,
+ strlen(event->filter_expression)) != 0) {
+ goto no_match;
+ }
+ }
+
return 1;
no_match:
return 1;
no_match:
@@
-353,8
+360,11
@@
static ssize_t list_events(struct agent_app *app, struct lttng_event **events)
for (i = 0; i < nb_event; i++) {
offset += len;
for (i = 0; i < nb_event; i++) {
offset += len;
- strncpy(tmp_events[i].name, reply->payload + offset,
- sizeof(tmp_events[i].name));
+ if (lttng_strncpy(tmp_events[i].name, reply->payload + offset,
+ sizeof(tmp_events[i].name))) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
tmp_events[i].pid = app->pid;
tmp_events[i].enabled = -1;
len = strlen(reply->payload + offset) + 1;
tmp_events[i].pid = app->pid;
tmp_events[i].enabled = -1;
len = strlen(reply->payload + offset) + 1;
@@
-380,7
+390,7
@@
error:
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-static int enable_event(struct agent_app *app, struct agent_event *event)
+static int enable_event(
const
struct agent_app *app, struct agent_event *event)
{
int ret;
char *bytes_to_send;
{
int ret;
char *bytes_to_send;
@@
-408,17
+418,20
@@
static int enable_event(struct agent_app *app, struct agent_event *event)
}
data_size = sizeof(msg) + filter_expression_length;
}
data_size = sizeof(msg) + filter_expression_length;
- ret = send_header(app->sock, data_size, AGENT_CMD_ENABLE, 0);
- if (ret < 0) {
- goto error_io;
- }
-
memset(&msg, 0, sizeof(msg));
msg.loglevel_value = htobe32(event->loglevel_value);
msg.loglevel_type = htobe32(event->loglevel_type);
memset(&msg, 0, sizeof(msg));
msg.loglevel_value = htobe32(event->loglevel_value);
msg.loglevel_type = htobe32(event->loglevel_type);
- strncpy(msg.name, event->name, sizeof(msg.name));
+ if (lttng_strncpy(msg.name, event->name, sizeof(msg.name))) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
msg.filter_expression_length = htobe32(filter_expression_length);
msg.filter_expression_length = htobe32(filter_expression_length);
+ ret = send_header(app->sock, data_size, AGENT_CMD_ENABLE, 0);
+ if (ret < 0) {
+ goto error_io;
+ }
+
bytes_to_send = zmalloc(data_size);
if (!bytes_to_send) {
ret = LTTNG_ERR_NOMEM;
bytes_to_send = zmalloc(data_size);
if (!bytes_to_send) {
ret = LTTNG_ERR_NOMEM;
@@
-492,8
+505,8
@@
end:
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-static int app_context_op(struct agent_app *app,
- struct agent_app_ctx *ctx, enum lttcomm_agent_command cmd)
+static int app_context_op(
const
struct agent_app *app,
+
const
struct agent_app_ctx *ctx, enum lttcomm_agent_command cmd)
{
int ret;
uint32_t reply_ret_code;
{
int ret;
uint32_t reply_ret_code;
@@
-591,14
+604,17
@@
static int disable_event(struct agent_app *app, struct agent_event *event)
app->pid, app->sock->fd);
data_size = sizeof(msg);
app->pid, app->sock->fd);
data_size = sizeof(msg);
+ memset(&msg, 0, sizeof(msg));
+ if (lttng_strncpy(msg.name, event->name, sizeof(msg.name))) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
ret = send_header(app->sock, data_size, AGENT_CMD_DISABLE, 0);
if (ret < 0) {
goto error_io;
}
ret = send_header(app->sock, data_size, AGENT_CMD_DISABLE, 0);
if (ret < 0) {
goto error_io;
}
- memset(&msg, 0, sizeof(msg));
- strncpy(msg.name, event->name, sizeof(msg.name));
ret = send_payload(app->sock, &msg, sizeof(msg));
if (ret < 0) {
goto error_io;
ret = send_payload(app->sock, &msg, sizeof(msg));
if (ret < 0) {
goto error_io;
@@
-692,7
+708,7
@@
void destroy_app_ctx(struct agent_app_ctx *ctx)
}
static
}
static
-struct agent_app_ctx *create_app_ctx(struct lttng_event_context *ctx)
+struct agent_app_ctx *create_app_ctx(
const
struct lttng_event_context *ctx)
{
struct agent_app_ctx *agent_ctx = NULL;
{
struct agent_app_ctx *agent_ctx = NULL;
@@
-722,7
+738,7
@@
end:
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int agent_enable_context(struct lttng_event_context *ctx,
+int agent_enable_context(
const
struct lttng_event_context *ctx,
enum lttng_domain_type domain)
{
int ret;
enum lttng_domain_type domain)
{
int ret;
@@
-939,7
+955,7
@@
struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
app = zmalloc(sizeof(*app));
if (!app) {
app = zmalloc(sizeof(*app));
if (!app) {
- PERROR("
zmalloc agent creat
e");
+ PERROR("
Failed to allocate agent application instanc
e");
goto error;
}
goto error;
}
@@
-1150,7
+1166,7
@@
void agent_add_event(struct agent_event *event, struct agent *agt)
/*
* Unique add of a agent context to an agent object.
*/
/*
* Unique add of a agent context to an agent object.
*/
-int agent_add_context(struct lttng_event_context *ctx, struct agent *agt)
+int agent_add_context(
const
struct lttng_event_context *ctx, struct agent *agt)
{
int ret = LTTNG_OK;
struct agent_app_ctx *agent_ctx = NULL;
{
int ret = LTTNG_OK;
struct agent_app_ctx *agent_ctx = NULL;
@@
-1395,26
+1411,24
@@
void agent_app_ht_clean(void)
* Note that this function is most likely to be used with a tracing session
* thus the caller should make sure to hold the appropriate lock(s).
*/
* Note that this function is most likely to be used with a tracing session
* thus the caller should make sure to hold the appropriate lock(s).
*/
-void agent_update(
struct agent *agt, int sock
)
+void agent_update(
const struct agent *agt, const struct agent_app *app
)
{
int ret;
{
int ret;
- struct agent_app *app;
struct agent_event *event;
struct lttng_ht_iter iter;
struct agent_app_ctx *ctx;
assert(agt);
struct agent_event *event;
struct lttng_ht_iter iter;
struct agent_app_ctx *ctx;
assert(agt);
- assert(
sock >= 0
);
+ assert(
app
);
- DBG("Agent updating app
socket %d", sock
);
+ DBG("Agent updating app
: pid = %ld", (long) app->pid
);
rcu_read_lock();
rcu_read_lock();
- app = agent_find_app_by_sock(sock);
/*
* We are in the registration path thus if the application is gone,
* there is a serious code flow error.
*/
/*
* We are in the registration path thus if the application is gone,
* there is a serious code flow error.
*/
- assert(app);
+
cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) {
/* Skip event if disabled. */
if (!event->enabled) {
cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) {
/* Skip event if disabled. */
if (!event->enabled) {
This page took
0.027832 seconds
and
4
git commands to generate.