/*
- * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _LGPL_SOURCE
*
* 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;
*
* 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;
}
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;
*
* 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;
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int disable_context(struct agent_app_ctx *ctx, enum lttng_domain_type domain)
+static int disable_context(struct agent_app_ctx *ctx,
+ enum lttng_domain_type domain)
{
int ret = LTTNG_OK;
struct agent_app *app;
app = zmalloc(sizeof(*app));
if (!app) {
- PERROR("zmalloc agent create");
+ PERROR("Failed to allocate agent application instance");
goto error;
}
/*
* 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;
* 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;
- struct agent_app *app;
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();
- 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.
*/
- assert(app);
+
cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) {
/* Skip event if disabled. */
if (!event->enabled) {