2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <urcu/uatomic.h>
22 #include <common/common.h>
23 #include <common/sessiond-comm/agent.h>
25 #include <common/compat/endian.h>
32 #define AGENT_RET_CODE_INDEX(code) (code - AGENT_RET_CODE_SUCCESS)
35 * Human readable agent return code.
37 static const char *error_string_array
[] = {
38 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_SUCCESS
) ] = "Success",
39 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_INVALID
) ] = "Invalid command",
40 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_UNKNOWN_NAME
) ] = "Unknown logger name",
43 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_NR
) ] = "Unknown code",
47 void log_reply_code(uint32_t in_reply_ret_code
)
49 int level
= PRINT_DBG3
;
51 * reply_ret_code and in_reply_ret_code are kept separate to have a
52 * sanitized value (used to retrieve the human readable string) and the
53 * original value which is logged as-is.
55 uint32_t reply_ret_code
= in_reply_ret_code
;
57 if (reply_ret_code
< AGENT_RET_CODE_SUCCESS
||
58 reply_ret_code
>= AGENT_RET_CODE_NR
) {
59 reply_ret_code
= AGENT_RET_CODE_NR
;
63 LOG(level
, "Agent replied with retcode: %s (%"PRIu32
")",
64 error_string_array
[AGENT_RET_CODE_INDEX(
70 * Match function for the events hash table lookup by name.
72 static int ht_match_event_by_name(struct cds_lfht_node
*node
,
75 struct agent_event
*event
;
76 const struct agent_ht_key
*key
;
81 event
= caa_container_of(node
, struct agent_event
, node
.node
);
84 /* Match 1 elements of the key: name. */
87 if (strncmp(event
->name
, key
->name
, sizeof(event
->name
)) != 0) {
98 * Match function for the events hash table lookup by name and loglevel.
100 static int ht_match_event(struct cds_lfht_node
*node
,
103 struct agent_event
*event
;
104 const struct agent_ht_key
*key
;
110 event
= caa_container_of(node
, struct agent_event
, node
.node
);
113 /* Match 2 elements of the key: name and loglevel. */
116 if (strncmp(event
->name
, key
->name
, sizeof(event
->name
)) != 0) {
120 /* Event loglevel value and type. */
121 ll_match
= loglevels_match(event
->loglevel_type
,
122 event
->loglevel_value
, key
->loglevel_type
,
123 key
->loglevel_value
, LTTNG_EVENT_LOGLEVEL_ALL
);
129 /* Filter expression */
130 if (strncmp(event
->filter_expression
, key
->filter_expression
,
131 strlen(event
->filter_expression
)) != 0) {
142 * Add unique agent event based on the event name and loglevel.
144 static void add_unique_agent_event(struct lttng_ht
*ht
,
145 struct agent_event
*event
)
147 struct cds_lfht_node
*node_ptr
;
148 struct agent_ht_key key
;
154 key
.name
= event
->name
;
155 key
.loglevel_value
= event
->loglevel_value
;
156 key
.loglevel_type
= event
->loglevel_type
;
157 key
.filter_expression
= event
->filter_expression
;
159 node_ptr
= cds_lfht_add_unique(ht
->ht
,
160 ht
->hash_fct(event
->node
.key
, lttng_ht_seed
),
161 ht_match_event
, &key
, &event
->node
.node
);
162 assert(node_ptr
== &event
->node
.node
);
166 * URCU delayed agent event reclaim.
168 static void destroy_event_agent_rcu(struct rcu_head
*head
)
170 struct lttng_ht_node_str
*node
=
171 caa_container_of(head
, struct lttng_ht_node_str
, head
);
172 struct agent_event
*event
=
173 caa_container_of(node
, struct agent_event
, node
);
175 agent_destroy_event(event
);
179 * URCU delayed agent app reclaim.
181 static void destroy_app_agent_rcu(struct rcu_head
*head
)
183 struct lttng_ht_node_ulong
*node
=
184 caa_container_of(head
, struct lttng_ht_node_ulong
, head
);
185 struct agent_app
*app
=
186 caa_container_of(node
, struct agent_app
, node
);
192 * Communication with the agent. Send the message header to the given socket in
195 * Return 0 on success or else a negative errno message of sendmsg() op.
197 static int send_header(struct lttcomm_sock
*sock
, uint64_t data_size
,
198 uint32_t cmd
, uint32_t cmd_version
)
202 struct lttcomm_agent_hdr msg
;
206 memset(&msg
, 0, sizeof(msg
));
207 msg
.data_size
= htobe64(data_size
);
208 msg
.cmd
= htobe32(cmd
);
209 msg
.cmd_version
= htobe32(cmd_version
);
211 size
= sock
->ops
->sendmsg(sock
, &msg
, sizeof(msg
), 0);
212 if (size
< sizeof(msg
)) {
223 * Communication call with the agent. Send the payload to the given socket. The
224 * header MUST be sent prior to this call.
226 * Return 0 on success or else a negative errno value of sendmsg() op.
228 static int send_payload(struct lttcomm_sock
*sock
, void *data
,
237 len
= sock
->ops
->sendmsg(sock
, data
, size
, 0);
249 * Communication call with the agent. Receive reply from the agent using the
252 * Return 0 on success or else a negative errno value from recvmsg() op.
254 static int recv_reply(struct lttcomm_sock
*sock
, void *buf
, size_t size
)
262 len
= sock
->ops
->recvmsg(sock
, buf
, size
, 0);
274 * Internal event listing for a given app. Populate events.
276 * Return number of element in the list or else a negative LTTNG_ERR* code.
277 * On success, the caller is responsible for freeing the memory
278 * allocated for "events".
280 static ssize_t
list_events(struct agent_app
*app
, struct lttng_event
**events
)
282 int ret
, i
, len
= 0, offset
= 0;
285 uint32_t reply_ret_code
;
286 struct lttng_event
*tmp_events
= NULL
;
287 struct lttcomm_agent_list_reply
*reply
= NULL
;
288 struct lttcomm_agent_list_reply_hdr reply_hdr
;
294 DBG2("Agent listing events for app pid: %d and socket %d", app
->pid
,
297 ret
= send_header(app
->sock
, 0, AGENT_CMD_LIST
, 0);
302 /* Get list header so we know how much we'll receive. */
303 ret
= recv_reply(app
->sock
, &reply_hdr
, sizeof(reply_hdr
));
308 reply_ret_code
= be32toh(reply_hdr
.ret_code
);
309 log_reply_code(reply_ret_code
);
310 switch (reply_ret_code
) {
311 case AGENT_RET_CODE_SUCCESS
:
312 data_size
= be32toh(reply_hdr
.data_size
) + sizeof(*reply
);
319 reply
= zmalloc(data_size
);
321 ret
= LTTNG_ERR_NOMEM
;
325 /* Get the list with the appropriate data size. */
326 ret
= recv_reply(app
->sock
, reply
, data_size
);
331 nb_event
= be32toh(reply
->nb_event
);
332 tmp_events
= zmalloc(sizeof(*tmp_events
) * nb_event
);
334 ret
= LTTNG_ERR_NOMEM
;
338 for (i
= 0; i
< nb_event
; i
++) {
340 strncpy(tmp_events
[i
].name
, reply
->payload
+ offset
,
341 sizeof(tmp_events
[i
].name
));
342 tmp_events
[i
].pid
= app
->pid
;
343 tmp_events
[i
].enabled
= -1;
344 len
= strlen(reply
->payload
+ offset
) + 1;
347 *events
= tmp_events
;
353 ret
= LTTNG_ERR_UST_LIST_FAIL
;
362 * Internal enable agent event on a agent application. This function
363 * communicates with the agent to enable a given event.
365 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
367 static int enable_event(struct agent_app
*app
, struct agent_event
*event
)
372 size_t filter_expression_length
;
373 uint32_t reply_ret_code
;
374 struct lttcomm_agent_enable msg
;
375 struct lttcomm_agent_generic_reply reply
;
381 DBG2("Agent enabling event %s for app pid: %d and socket %d", event
->name
,
382 app
->pid
, app
->sock
->fd
);
385 * Calculate the payload's size, which is the fixed-size struct followed
386 * by the variable-length filter expression (+1 for the ending \0).
388 if (!event
->filter_expression
) {
389 filter_expression_length
= 0;
391 filter_expression_length
= strlen(event
->filter_expression
) + 1;
393 data_size
= sizeof(msg
) + filter_expression_length
;
395 ret
= send_header(app
->sock
, data_size
, AGENT_CMD_ENABLE
, 0);
400 memset(&msg
, 0, sizeof(msg
));
401 msg
.loglevel_value
= htobe32(event
->loglevel_value
);
402 msg
.loglevel_type
= htobe32(event
->loglevel_type
);
403 strncpy(msg
.name
, event
->name
, sizeof(msg
.name
));
404 msg
.filter_expression_length
= htobe32(filter_expression_length
);
406 bytes_to_send
= zmalloc(data_size
);
407 if (!bytes_to_send
) {
408 ret
= LTTNG_ERR_NOMEM
;
412 memcpy(bytes_to_send
, &msg
, sizeof(msg
));
413 if (filter_expression_length
> 0) {
414 memcpy(bytes_to_send
+ sizeof(msg
), event
->filter_expression
,
415 filter_expression_length
);
418 ret
= send_payload(app
->sock
, bytes_to_send
, data_size
);
424 ret
= recv_reply(app
->sock
, &reply
, sizeof(reply
));
429 reply_ret_code
= be32toh(reply
.ret_code
);
430 log_reply_code(reply_ret_code
);
431 switch (reply_ret_code
) {
432 case AGENT_RET_CODE_SUCCESS
:
434 case AGENT_RET_CODE_UNKNOWN_NAME
:
435 ret
= LTTNG_ERR_UST_EVENT_NOT_FOUND
;
445 ret
= LTTNG_ERR_UST_ENABLE_FAIL
;
451 * Internal disable agent event call on a agent application. This function
452 * communicates with the agent to disable a given event.
454 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
456 static int disable_event(struct agent_app
*app
, struct agent_event
*event
)
460 uint32_t reply_ret_code
;
461 struct lttcomm_agent_disable msg
;
462 struct lttcomm_agent_generic_reply reply
;
468 DBG2("Agent disabling event %s for app pid: %d and socket %d", event
->name
,
469 app
->pid
, app
->sock
->fd
);
471 data_size
= sizeof(msg
);
473 ret
= send_header(app
->sock
, data_size
, AGENT_CMD_DISABLE
, 0);
478 memset(&msg
, 0, sizeof(msg
));
479 strncpy(msg
.name
, event
->name
, sizeof(msg
.name
));
480 ret
= send_payload(app
->sock
, &msg
, sizeof(msg
));
485 ret
= recv_reply(app
->sock
, &reply
, sizeof(reply
));
490 reply_ret_code
= be32toh(reply
.ret_code
);
491 log_reply_code(reply_ret_code
);
492 switch (reply_ret_code
) {
493 case AGENT_RET_CODE_SUCCESS
:
495 case AGENT_RET_CODE_UNKNOWN_NAME
:
496 ret
= LTTNG_ERR_UST_EVENT_NOT_FOUND
;
506 ret
= LTTNG_ERR_UST_DISABLE_FAIL
;
512 * Send back the registration DONE command to a given agent application.
514 * Return 0 on success or else a negative value.
516 int agent_send_registration_done(struct agent_app
*app
)
521 DBG("Agent sending registration done to app socket %d", app
->sock
->fd
);
523 return send_header(app
->sock
, 0, AGENT_CMD_REG_DONE
, 0);
527 * Enable agent event on every agent applications registered with the session
530 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
532 int agent_enable_event(struct agent_event
*event
,
533 enum lttng_domain_type domain
)
536 struct agent_app
*app
;
537 struct lttng_ht_iter iter
;
543 cds_lfht_for_each_entry(agent_apps_ht_by_sock
->ht
, &iter
.iter
, app
,
545 if (app
->domain
!= domain
) {
549 /* Enable event on agent application through TCP socket. */
550 ret
= enable_event(app
, event
);
551 if (ret
!= LTTNG_OK
) {
565 * Disable agent event on every agent applications registered with the session
568 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
570 int agent_disable_event(struct agent_event
*event
,
571 enum lttng_domain_type domain
)
574 struct agent_app
*app
;
575 struct lttng_ht_iter iter
;
578 if (!event
->enabled
) {
584 cds_lfht_for_each_entry(agent_apps_ht_by_sock
->ht
, &iter
.iter
, app
,
586 if (app
->domain
!= domain
) {
590 /* Enable event on agent application through TCP socket. */
591 ret
= disable_event(app
, event
);
592 if (ret
!= LTTNG_OK
) {
606 * Ask every agent for the list of possible event. Events is allocated with the
607 * events of every agent application.
609 * Return the number of events or else a negative value.
611 int agent_list_events(struct lttng_event
**events
,
612 enum lttng_domain_type domain
)
615 size_t nbmem
, count
= 0;
616 struct agent_app
*app
;
617 struct lttng_event
*tmp_events
= NULL
;
618 struct lttng_ht_iter iter
;
622 DBG2("Agent listing events for domain %d", domain
);
624 nbmem
= UST_APP_EVENT_LIST_SIZE
;
625 tmp_events
= zmalloc(nbmem
* sizeof(*tmp_events
));
627 PERROR("zmalloc agent list events");
633 cds_lfht_for_each_entry(agent_apps_ht_by_sock
->ht
, &iter
.iter
, app
,
636 struct lttng_event
*agent_events
;
638 /* Skip domain not asked by the list. */
639 if (app
->domain
!= domain
) {
643 nb_ev
= list_events(app
, &agent_events
);
649 if (count
+ nb_ev
> nbmem
) {
650 /* In case the realloc fails, we free the memory */
651 struct lttng_event
*new_tmp_events
;
654 new_nbmem
= max_t(size_t, count
+ nb_ev
, nbmem
<< 1);
655 DBG2("Reallocating agent event list from %zu to %zu entries",
657 new_tmp_events
= realloc(tmp_events
,
658 new_nbmem
* sizeof(*new_tmp_events
));
659 if (!new_tmp_events
) {
660 PERROR("realloc agent events");
665 /* Zero the new memory */
666 memset(new_tmp_events
+ nbmem
, 0,
667 (new_nbmem
- nbmem
) * sizeof(*new_tmp_events
));
669 tmp_events
= new_tmp_events
;
671 memcpy(tmp_events
+ count
, agent_events
,
672 nb_ev
* sizeof(*tmp_events
));
679 *events
= tmp_events
;
690 * Create a agent app object using the given PID.
692 * Return newly allocated object or else NULL on error.
694 struct agent_app
*agent_create_app(pid_t pid
, enum lttng_domain_type domain
,
695 struct lttcomm_sock
*sock
)
697 struct agent_app
*app
;
701 app
= zmalloc(sizeof(*app
));
703 PERROR("zmalloc agent create");
708 app
->domain
= domain
;
710 lttng_ht_node_init_ulong(&app
->node
, (unsigned long) app
->sock
->fd
);
717 * Lookup agent app by socket in the global hash table.
719 * RCU read side lock MUST be acquired.
721 * Return object if found else NULL.
723 struct agent_app
*agent_find_app_by_sock(int sock
)
725 struct lttng_ht_node_ulong
*node
;
726 struct lttng_ht_iter iter
;
727 struct agent_app
*app
;
731 lttng_ht_lookup(agent_apps_ht_by_sock
, (void *)((unsigned long) sock
), &iter
);
732 node
= lttng_ht_iter_get_node_ulong(&iter
);
736 app
= caa_container_of(node
, struct agent_app
, node
);
738 DBG3("Agent app pid %d found by sock %d.", app
->pid
, sock
);
742 DBG3("Agent app NOT found by sock %d.", sock
);
747 * Add agent application object to the global hash table.
749 void agent_add_app(struct agent_app
*app
)
753 DBG3("Agent adding app sock: %d and pid: %d to ht", app
->sock
->fd
, app
->pid
);
754 lttng_ht_add_unique_ulong(agent_apps_ht_by_sock
, &app
->node
);
758 * Delete agent application from the global hash table.
760 * rcu_read_lock() must be held by the caller.
762 void agent_delete_app(struct agent_app
*app
)
765 struct lttng_ht_iter iter
;
769 DBG3("Agent deleting app pid: %d and sock: %d", app
->pid
, app
->sock
->fd
);
771 iter
.iter
.node
= &app
->node
.node
;
772 ret
= lttng_ht_del(agent_apps_ht_by_sock
, &iter
);
777 * Destroy an agent application object by detaching it from its corresponding
778 * UST app if one is connected by closing the socket. Finally, perform a
779 * delayed memory reclaim.
781 void agent_destroy_app(struct agent_app
*app
)
786 app
->sock
->ops
->close(app
->sock
);
787 lttcomm_destroy_sock(app
->sock
);
790 call_rcu(&app
->node
.head
, destroy_app_agent_rcu
);
794 * Initialize an already allocated agent object.
796 * Return 0 on success or else a negative errno value.
798 int agent_init(struct agent
*agt
)
804 agt
->events
= lttng_ht_new(0, LTTNG_HT_TYPE_STRING
);
809 lttng_ht_node_init_u64(&agt
->node
, agt
->domain
);
818 * Add agent object to the given hash table.
820 void agent_add(struct agent
*agt
, struct lttng_ht
*ht
)
825 DBG3("Agent adding from domain %d", agt
->domain
);
827 lttng_ht_add_unique_u64(ht
, &agt
->node
);
831 * Create an agent object for the given domain.
833 * Return the allocated agent or NULL on error.
835 struct agent
*agent_create(enum lttng_domain_type domain
)
840 agt
= zmalloc(sizeof(struct agent
));
844 agt
->domain
= domain
;
846 ret
= agent_init(agt
);
858 * Create a newly allocated agent event data structure.
859 * Ownership of filter_expression is taken.
861 * Return a new object else NULL on error.
863 struct agent_event
*agent_create_event(const char *name
,
864 enum lttng_loglevel_type loglevel_type
, int loglevel_value
,
865 struct lttng_filter_bytecode
*filter
, char *filter_expression
)
867 struct agent_event
*event
= NULL
;
869 DBG3("Agent create new event with name %s, loglevel type %d, \
870 loglevel value %d and filter %s",
871 name
, loglevel_type
, loglevel_value
,
872 filter_expression
? filter_expression
: "NULL");
875 ERR("Failed to create agent event; no name provided.");
879 event
= zmalloc(sizeof(*event
));
884 strncpy(event
->name
, name
, sizeof(event
->name
));
885 event
->name
[sizeof(event
->name
) - 1] = '\0';
886 lttng_ht_node_init_str(&event
->node
, event
->name
);
888 event
->loglevel_value
= loglevel_value
;
889 event
->loglevel_type
= loglevel_type
;
890 event
->filter
= filter
;
891 event
->filter_expression
= filter_expression
;
897 * Unique add of a agent event to an agent object.
899 void agent_add_event(struct agent_event
*event
, struct agent
*agt
)
905 DBG3("Agent adding event %s", event
->name
);
906 add_unique_agent_event(agt
->events
, event
);
911 * Find multiple agent events sharing the given name.
913 * RCU read side lock MUST be acquired. It must be held for the
914 * duration of the iteration.
916 * Sets the given iterator.
918 void agent_find_events_by_name(const char *name
, struct agent
*agt
,
919 struct lttng_ht_iter
* iter
)
922 struct agent_ht_key key
;
932 cds_lfht_lookup(ht
->ht
, ht
->hash_fct((void *) name
, lttng_ht_seed
),
933 ht_match_event_by_name
, &key
, &iter
->iter
);
937 * Get the next agent event duplicate by name. This should be called
938 * after a call to agent_find_events_by_name() to iterate on events.
940 * The RCU read lock must be held during the iteration and for as long
941 * as the object the iterator points to remains in use.
943 void agent_event_next_duplicate(const char *name
,
944 struct agent
*agt
, struct lttng_ht_iter
* iter
)
946 struct agent_ht_key key
;
950 cds_lfht_next_duplicate(agt
->events
->ht
, ht_match_event_by_name
,
955 * Find a agent event in the given agent using name, loglevel and filter.
957 * RCU read side lock MUST be acquired. It must be kept for as long as
958 * the returned agent_event is used.
960 * Return object if found else NULL.
962 struct agent_event
*agent_find_event(const char *name
,
963 enum lttng_loglevel_type loglevel_type
, int loglevel_value
,
964 char *filter_expression
, struct agent
*agt
)
966 struct lttng_ht_node_str
*node
;
967 struct lttng_ht_iter iter
;
969 struct agent_ht_key key
;
977 key
.loglevel_value
= loglevel_value
;
978 key
.loglevel_type
= loglevel_type
;
979 key
.filter_expression
= filter_expression
;
981 cds_lfht_lookup(ht
->ht
, ht
->hash_fct((void *) name
, lttng_ht_seed
),
982 ht_match_event
, &key
, &iter
.iter
);
983 node
= lttng_ht_iter_get_node_str(&iter
);
988 DBG3("Agent event found %s.", name
);
989 return caa_container_of(node
, struct agent_event
, node
);
992 DBG3("Agent event NOT found %s.", name
);
997 * Free given agent event. This event must not be globally visible at this
998 * point (only expected to be used on failure just after event creation). After
999 * this call, the pointer is not usable anymore.
1001 void agent_destroy_event(struct agent_event
*event
)
1005 free(event
->filter
);
1006 free(event
->filter_expression
);
1007 free(event
->exclusion
);
1012 * Destroy an agent completely.
1014 void agent_destroy(struct agent
*agt
)
1016 struct lttng_ht_node_str
*node
;
1017 struct lttng_ht_iter iter
;
1021 DBG3("Agent destroy");
1024 cds_lfht_for_each_entry(agt
->events
->ht
, &iter
.iter
, node
, node
) {
1026 struct agent_event
*event
;
1029 * When destroying an event, we have to try to disable it on the agent
1030 * side so the event stops generating data. The return value is not
1031 * important since we have to continue anyway destroying the object.
1033 event
= caa_container_of(node
, struct agent_event
, node
);
1034 (void) agent_disable_event(event
, agt
->domain
);
1036 ret
= lttng_ht_del(agt
->events
, &iter
);
1038 call_rcu(&node
->head
, destroy_event_agent_rcu
);
1042 ht_cleanup_push(agt
->events
);
1047 * Allocate agent_apps_ht_by_sock.
1049 int agent_app_ht_alloc(void)
1053 agent_apps_ht_by_sock
= lttng_ht_new(0, LTTNG_HT_TYPE_ULONG
);
1054 if (!agent_apps_ht_by_sock
) {
1062 * Destroy a agent application by socket.
1064 void agent_destroy_app_by_sock(int sock
)
1066 struct agent_app
*app
;
1071 * Not finding an application is a very important error that should NEVER
1072 * happen. The hash table deletion is ONLY done through this call when the
1073 * main sessiond thread is torn down.
1076 app
= agent_find_app_by_sock(sock
);
1079 /* RCU read side lock is assumed to be held by this function. */
1080 agent_delete_app(app
);
1082 /* The application is freed in a RCU call but the socket is closed here. */
1083 agent_destroy_app(app
);
1088 * Clean-up the agent app hash table and destroy it.
1090 void agent_app_ht_clean(void)
1092 struct lttng_ht_node_ulong
*node
;
1093 struct lttng_ht_iter iter
;
1095 if (!agent_apps_ht_by_sock
) {
1099 cds_lfht_for_each_entry(agent_apps_ht_by_sock
->ht
, &iter
.iter
, node
, node
) {
1100 struct agent_app
*app
;
1102 app
= caa_container_of(node
, struct agent_app
, node
);
1103 agent_destroy_app_by_sock(app
->sock
->fd
);
1107 lttng_ht_destroy(agent_apps_ht_by_sock
);
1111 * Update a agent application (given socket) using the given agent.
1113 * Note that this function is most likely to be used with a tracing session
1114 * thus the caller should make sure to hold the appropriate lock(s).
1116 void agent_update(struct agent
*agt
, int sock
)
1119 struct agent_app
*app
;
1120 struct agent_event
*event
;
1121 struct lttng_ht_iter iter
;
1126 DBG("Agent updating app socket %d", sock
);
1129 cds_lfht_for_each_entry(agt
->events
->ht
, &iter
.iter
, event
, node
.node
) {
1130 /* Skip event if disabled. */
1131 if (!event
->enabled
) {
1135 app
= agent_find_app_by_sock(sock
);
1137 * We are in the registration path thus if the application is gone,
1138 * there is a serious code flow error.
1142 ret
= enable_event(app
, event
);
1143 if (ret
!= LTTNG_OK
) {
1144 DBG2("Agent update unable to enable event %s on app pid: %d sock %d",
1145 event
->name
, app
->pid
, app
->sock
->fd
);
1146 /* Let's try the others here and don't assume the app is dead. */