projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: memleaks in channel/event notify
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
ust-app.c
diff --git
a/src/bin/lttng-sessiond/ust-app.c
b/src/bin/lttng-sessiond/ust-app.c
index 396ca936e004d751633fb6a8fce41cfd9c0b61cd..7e7c89a481d5fab4019b470ca45b4bcb7c3c4c5d 100644
(file)
--- a/
src/bin/lttng-sessiond/ust-app.c
+++ b/
src/bin/lttng-sessiond/ust-app.c
@@
-38,6
+38,7
@@
#include "ust-app.h"
#include "ust-consumer.h"
#include "ust-ctl.h"
#include "ust-app.h"
#include "ust-consumer.h"
#include "ust-ctl.h"
+#include "utils.h"
/* Next available channel key. */
static unsigned long next_channel_key;
/* Next available channel key. */
static unsigned long next_channel_key;
@@
-307,9
+308,9
@@
void delete_ust_app_stream(int sock, struct ust_app_stream *stream)
/*
* We need to execute ht_destroy outside of RCU read-side critical
/*
* We need to execute ht_destroy outside of RCU read-side critical
- * section
, so we postpone its execution using call_rcu. It is simpler
- *
than to change the semantic of the many callers
of
- *
delete_ust_app_channel
().
+ * section
and outside of call_rcu thread, so we postpone its execution
+ *
using ht_cleanup_push. It is simpler than to change the semantic
of
+ *
the many callers of delete_ust_app_session
().
*/
static
void delete_ust_app_channel_rcu(struct rcu_head *head)
*/
static
void delete_ust_app_channel_rcu(struct rcu_head *head)
@@
-317,8
+318,8
@@
void delete_ust_app_channel_rcu(struct rcu_head *head)
struct ust_app_channel *ua_chan =
caa_container_of(head, struct ust_app_channel, rcu_head);
struct ust_app_channel *ua_chan =
caa_container_of(head, struct ust_app_channel, rcu_head);
-
lttng_ht_destroy
(ua_chan->ctx);
-
lttng_ht_destroy
(ua_chan->events);
+
ht_cleanup_push
(ua_chan->ctx);
+
ht_cleanup_push
(ua_chan->events);
free(ua_chan);
}
free(ua_chan);
}
@@
-583,9
+584,9
@@
end:
/*
* We need to execute ht_destroy outside of RCU read-side critical
/*
* We need to execute ht_destroy outside of RCU read-side critical
- * section
, so we postpone its execution using call_rcu. It is simpler
- *
than to change the semantic of the many callers
of
- * delete_ust_app_session().
+ * section
and outside of call_rcu thread, so we postpone its execution
+ *
using ht_cleanup_push. It is simpler than to change the semantic
of
+ *
the many callers of
delete_ust_app_session().
*/
static
void delete_ust_app_session_rcu(struct rcu_head *head)
*/
static
void delete_ust_app_session_rcu(struct rcu_head *head)
@@
-593,7
+594,7
@@
void delete_ust_app_session_rcu(struct rcu_head *head)
struct ust_app_session *ua_sess =
caa_container_of(head, struct ust_app_session, rcu_head);
struct ust_app_session *ua_sess =
caa_container_of(head, struct ust_app_session, rcu_head);
-
lttng_ht_destroy
(ua_sess->channels);
+
ht_cleanup_push
(ua_sess->channels);
free(ua_sess);
}
free(ua_sess);
}
@@
-685,8
+686,8
@@
void delete_ust_app(struct ust_app *app)
rcu_read_unlock();
}
rcu_read_unlock();
}
-
lttng_ht_destroy
(app->sessions);
-
lttng_ht_destroy
(app->ust_objd);
+
ht_cleanup_push
(app->sessions);
+
ht_cleanup_push
(app->ust_objd);
/*
* Wait until we have deleted the application from the sock hash table
/*
* Wait until we have deleted the application from the sock hash table
@@
-3155,9
+3156,9
@@
void ust_app_clean_list(void)
rcu_read_unlock();
/* Destroy is done only when the ht is empty */
rcu_read_unlock();
/* Destroy is done only when the ht is empty */
-
lttng_ht_destroy
(ust_app_ht);
-
lttng_ht_destroy
(ust_app_ht_by_sock);
-
lttng_ht_destroy
(ust_app_ht_by_notify_sock);
+
ht_cleanup_push
(ust_app_ht);
+
ht_cleanup_push
(ust_app_ht_by_sock);
+
ht_cleanup_push
(ust_app_ht_by_notify_sock);
}
/*
}
/*
@@
-4475,9
+4476,14
@@
static int reply_ust_register_channel(int sock, int sobjd, int cobjd,
goto error_rcu_unlock;
}
goto error_rcu_unlock;
}
- /* Lookup channel by UST object descriptor.
Should always be found.
*/
+ /* Lookup channel by UST object descriptor. */
ua_chan = find_channel_by_objd(app, cobjd);
ua_chan = find_channel_by_objd(app, cobjd);
- assert(ua_chan);
+ if (!ua_chan) {
+ DBG("Application channel is being teardown. Abort event notify");
+ ret = 0;
+ goto error_rcu_unlock;
+ }
+
assert(ua_chan->session);
ua_sess = ua_chan->session;
assert(ua_chan->session);
ua_sess = ua_chan->session;
@@
-4581,9
+4587,14
@@
static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name,
goto error_rcu_unlock;
}
goto error_rcu_unlock;
}
- /* Lookup channel by UST object descriptor.
Should always be found.
*/
+ /* Lookup channel by UST object descriptor. */
ua_chan = find_channel_by_objd(app, cobjd);
ua_chan = find_channel_by_objd(app, cobjd);
- assert(ua_chan);
+ if (!ua_chan) {
+ DBG("Application channel is being teardown. Abort event notify");
+ ret = 0;
+ goto error_rcu_unlock;
+ }
+
assert(ua_chan->session);
ua_sess = ua_chan->session;
assert(ua_chan->session);
ua_sess = ua_chan->session;
@@
-4678,6
+4689,9
@@
int ust_app_recv_notify(int sock)
ret = add_event_ust_registry(sock, sobjd, cobjd, name, sig, nr_fields,
fields, loglevel, model_emf_uri);
if (ret < 0) {
ret = add_event_ust_registry(sock, sobjd, cobjd, name, sig, nr_fields,
fields, loglevel, model_emf_uri);
if (ret < 0) {
+ free(sig);
+ free(model_emf_uri);
+ free(fields);
goto error;
}
goto error;
}
@@
-4705,6
+4719,7
@@
int ust_app_recv_notify(int sock)
ret = reply_ust_register_channel(sock, sobjd, cobjd, nr_fields,
fields);
if (ret < 0) {
ret = reply_ust_register_channel(sock, sobjd, cobjd, nr_fields,
fields);
if (ret < 0) {
+ free(fields);
goto error;
}
goto error;
}
@@
-4795,3
+4810,15
@@
close_socket:
call_rcu(&obj->head, close_notify_sock_rcu);
}
}
call_rcu(&obj->head, close_notify_sock_rcu);
}
}
+
+/*
+ * Destroy a ust app data structure and free its memory.
+ */
+void ust_app_destroy(struct ust_app *app)
+{
+ if (!app) {
+ return;
+ }
+
+ call_rcu(&app->pid_n.head, delete_ust_app_rcu);
+}
This page took
0.026834 seconds
and
4
git commands to generate.