projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: fd leak in process client msg error path
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
main.c
diff --git
a/src/bin/lttng-sessiond/main.c
b/src/bin/lttng-sessiond/main.c
index f6a051aa1cb52f8080cc9b2209a71044f052e860..c3f8ab3bdbc7dfb8aff2c5eca9b146276c6ac22d 100644
(file)
--- a/
src/bin/lttng-sessiond/main.c
+++ b/
src/bin/lttng-sessiond/main.c
@@
-232,6
+232,9
@@
static enum consumerd_state kernel_consumerd_state;
*/
static int app_socket_timeout;
*/
static int app_socket_timeout;
+/* Set in main() with the current page size. */
+long page_size;
+
static
void setup_consumerd_path(void)
{
static
void setup_consumerd_path(void)
{
@@
-2159,6
+2162,8
@@
error:
* Copy consumer output from the tracing session to the domain session. The
* function also applies the right modification on a per domain basis for the
* trace files destination directory.
* Copy consumer output from the tracing session to the domain session. The
* function also applies the right modification on a per domain basis for the
* trace files destination directory.
+ *
+ * Should *NOT* be called with RCU read-side lock held.
*/
static int copy_session_consumer(int domain, struct ltt_session *session)
{
*/
static int copy_session_consumer(int domain, struct ltt_session *session)
{
@@
-2216,6
+2221,8
@@
error:
/*
* Create an UST session and add it to the session ust list.
/*
* Create an UST session and add it to the session ust list.
+ *
+ * Should *NOT* be called with RCU read-side lock held.
*/
static int create_ust_session(struct ltt_session *session,
struct lttng_domain *domain)
*/
static int create_ust_session(struct ltt_session *session,
struct lttng_domain *domain)
@@
-2341,6
+2348,8
@@
static unsigned int lttng_sessions_count(uid_t uid, gid_t gid)
* Return any error encountered or 0 for success.
*
* "sock" is only used for special-case var. len data.
* Return any error encountered or 0 for success.
*
* "sock" is only used for special-case var. len data.
+ *
+ * Should *NOT* be called with RCU read-side lock held.
*/
static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
int *sock_error)
*/
static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
int *sock_error)
@@
-2886,6
+2895,7
@@
skip_domain:
ret = setup_lttng_msg(cmd_ctx, nb_dom * sizeof(struct lttng_domain));
if (ret < 0) {
ret = setup_lttng_msg(cmd_ctx, nb_dom * sizeof(struct lttng_domain));
if (ret < 0) {
+ free(domains);
goto setup_error;
}
goto setup_error;
}
@@
-2913,6
+2923,7
@@
skip_domain:
ret = setup_lttng_msg(cmd_ctx, nb_chan * sizeof(struct lttng_channel));
if (ret < 0) {
ret = setup_lttng_msg(cmd_ctx, nb_chan * sizeof(struct lttng_channel));
if (ret < 0) {
+ free(channels);
goto setup_error;
}
goto setup_error;
}
@@
-2940,6
+2951,7
@@
skip_domain:
ret = setup_lttng_msg(cmd_ctx, nb_event * sizeof(struct lttng_event));
if (ret < 0) {
ret = setup_lttng_msg(cmd_ctx, nb_event * sizeof(struct lttng_event));
if (ret < 0) {
+ free(events);
goto setup_error;
}
goto setup_error;
}
@@
-3437,13
+3449,11
@@
static void *thread_manage_clients(void *data)
ret = process_client_msg(cmd_ctx, sock, &sock_error);
rcu_thread_offline();
if (ret < 0) {
ret = process_client_msg(cmd_ctx, sock, &sock_error);
rcu_thread_offline();
if (ret < 0) {
- if (sock_error) {
- ret = close(sock);
- if (ret) {
- PERROR("close");
- }
- sock = -1;
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
}
}
+ sock = -1;
/*
* TODO: Inform client somehow of the fatal error. At
* this point, ret < 0 means that a zmalloc failed
/*
* TODO: Inform client somehow of the fatal error. At
* this point, ret < 0 means that a zmalloc failed
@@
-4032,6
+4042,13
@@
int main(int argc, char **argv)
setup_consumerd_path();
setup_consumerd_path();
+ page_size = sysconf(_SC_PAGESIZE);
+ if (page_size < 0) {
+ PERROR("sysconf _SC_PAGESIZE");
+ page_size = LONG_MAX;
+ WARN("Fallback page size to %ld", page_size);
+ }
+
/* Parse arguments */
progname = argv[0];
if ((ret = parse_args(argc, argv)) < 0) {
/* Parse arguments */
progname = argv[0];
if ((ret = parse_args(argc, argv)) < 0) {
This page took
0.02782 seconds
and
4
git commands to generate.