projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: Delete UST app session on ustctl create error
[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 10ffe403bc44448a9d9511fb60e3983345988829..5380450f643a31cce3fa3e2eb1bb8ca994fb20ff 100644
(file)
--- a/
src/bin/lttng-sessiond/ust-app.c
+++ b/
src/bin/lttng-sessiond/ust-app.c
@@
-31,6
+31,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 "fd-limit.h"
/*
* Delete ust context safely. RCU read lock must be held before calling
/*
* Delete ust context safely. RCU read lock must be held before calling
@@
-82,6
+83,7
@@
void delete_ust_app_stream(int sock, struct ltt_ust_stream *stream)
{
if (stream->obj) {
ustctl_release_object(sock, stream->obj);
{
if (stream->obj) {
ustctl_release_object(sock, stream->obj);
+ lttng_fd_put(LTTNG_FD_APPS, 2);
free(stream->obj);
}
free(stream);
free(stream->obj);
}
free(stream);
@@
-125,6
+127,7
@@
void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan)
if (ua_chan->obj != NULL) {
ustctl_release_object(sock, ua_chan->obj);
if (ua_chan->obj != NULL) {
ustctl_release_object(sock, ua_chan->obj);
+ lttng_fd_put(LTTNG_FD_APPS, 2);
free(ua_chan->obj);
}
free(ua_chan);
free(ua_chan->obj);
}
free(ua_chan);
@@
-144,12
+147,15
@@
void delete_ust_app_session(int sock, struct ust_app_session *ua_sess)
if (ua_sess->metadata) {
if (ua_sess->metadata->stream_obj) {
ustctl_release_object(sock, ua_sess->metadata->stream_obj);
if (ua_sess->metadata) {
if (ua_sess->metadata->stream_obj) {
ustctl_release_object(sock, ua_sess->metadata->stream_obj);
+ lttng_fd_put(LTTNG_FD_APPS, 2);
free(ua_sess->metadata->stream_obj);
}
if (ua_sess->metadata->obj) {
ustctl_release_object(sock, ua_sess->metadata->obj);
free(ua_sess->metadata->stream_obj);
}
if (ua_sess->metadata->obj) {
ustctl_release_object(sock, ua_sess->metadata->obj);
+ lttng_fd_put(LTTNG_FD_APPS, 2);
free(ua_sess->metadata->obj);
}
free(ua_sess->metadata->obj);
}
+ trace_ust_destroy_metadata(ua_sess->metadata);
}
cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
}
cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
@@
-209,6
+215,7
@@
void delete_ust_app(struct ust_app *app)
if (ret) {
PERROR("close");
}
if (ret) {
PERROR("close");
}
+ lttng_fd_put(LTTNG_FD_APPS, 1);
DBG2("UST app pid %d deleted", app->pid);
free(app);
DBG2("UST app pid %d deleted", app->pid);
free(app);
@@
-535,6
+542,12
@@
static int open_ust_metadata(struct ust_app *app,
ua_sess->metadata->attr.read_timer_interval;
uattr.output = ua_sess->metadata->attr.output;
ua_sess->metadata->attr.read_timer_interval;
uattr.output = ua_sess->metadata->attr.output;
+ /* We are going to receive 2 fds, we need to reserve them. */
+ ret = lttng_fd_get(LTTNG_FD_APPS, 2);
+ if (ret < 0) {
+ ERR("Exhausted number of available FD upon metadata open");
+ goto error;
+ }
/* UST tracer metadata creation */
ret = ustctl_open_metadata(app->sock, ua_sess->handle, &uattr,
&ua_sess->metadata->obj);
/* UST tracer metadata creation */
ret = ustctl_open_metadata(app->sock, ua_sess->handle, &uattr,
&ua_sess->metadata->obj);
@@
-558,6
+571,12
@@
static int create_ust_stream(struct ust_app *app,
{
int ret;
{
int ret;
+ /* We are going to receive 2 fds, we need to reserve them. */
+ ret = lttng_fd_get(LTTNG_FD_APPS, 2);
+ if (ret < 0) {
+ ERR("Exhausted number of available FD upon metadata stream create");
+ goto error;
+ }
ret = ustctl_create_stream(app->sock, ua_sess->metadata->obj,
&ua_sess->metadata->stream_obj);
if (ret < 0) {
ret = ustctl_create_stream(app->sock, ua_sess->metadata->obj,
&ua_sess->metadata->stream_obj);
if (ret < 0) {
@@
-578,6
+597,13
@@
static int create_ust_channel(struct ust_app *app,
int ret;
/* TODO: remove cast and use lttng-ust-abi.h */
int ret;
/* TODO: remove cast and use lttng-ust-abi.h */
+
+ /* We are going to receive 2 fds, we need to reserve them. */
+ ret = lttng_fd_get(LTTNG_FD_APPS, 2);
+ if (ret < 0) {
+ ERR("Exhausted number of available FD upon create channel");
+ goto error;
+ }
ret = ustctl_create_channel(app->sock, ua_sess->handle,
(struct lttng_ust_channel_attr *)&ua_chan->attr, &ua_chan->obj);
if (ret < 0) {
ret = ustctl_create_channel(app->sock, ua_sess->handle,
(struct lttng_ust_channel_attr *)&ua_chan->attr, &ua_chan->obj);
if (ret < 0) {
@@
-585,6
+611,7
@@
static int create_ust_channel(struct ust_app *app,
"and session handle %d with ret %d",
ua_chan->name, app->pid, app->sock,
ua_sess->handle, ret);
"and session handle %d with ret %d",
ua_chan->name, app->pid, app->sock,
ua_sess->handle, ret);
+ lttng_fd_put(LTTNG_FD_APPS, 2);
goto error;
}
goto error;
}
@@
-618,7
+645,7
@@
int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
&ua_event->obj);
if (ret < 0) {
ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
&ua_event->obj);
if (ret < 0) {
- if (ret == -EEXIST) {
+ if (ret == -EEXIST
|| ret == -EPERM
) {
ret = 0;
goto error;
}
ret = 0;
goto error;
}
@@
-867,8
+894,9
@@
static struct ust_app_session *create_ust_app_session(
if (ret < 0) {
ERR("Creating session for app pid %d", app->pid);
/* This means that the tracer is gone... */
if (ret < 0) {
ERR("Creating session for app pid %d", app->pid);
/* This means that the tracer is gone... */
+ delete_ust_app_session(-1, ua_sess);
ua_sess = (void*) -1UL;
ua_sess = (void*) -1UL;
- goto e
rror
;
+ goto e
nd
;
}
ua_sess->handle = ret;
}
ua_sess->handle = ret;
@@
-882,10
+910,6
@@
static struct ust_app_session *create_ust_app_session(
end:
return ua_sess;
end:
return ua_sess;
-
-error:
- delete_ust_app_session(-1, ua_sess);
- return NULL;
}
/*
}
/*
@@
-1280,6
+1304,7
@@
int ust_app_register(struct ust_register_msg *msg, int sock)
if (ret) {
PERROR("close");
}
if (ret) {
PERROR("close");
}
+ lttng_fd_put(LTTNG_FD_APPS, 1);
return -EINVAL;
}
if (msg->major != LTTNG_UST_COMM_MAJOR) {
return -EINVAL;
}
if (msg->major != LTTNG_UST_COMM_MAJOR) {
@@
-1290,6
+1315,7
@@
int ust_app_register(struct ust_register_msg *msg, int sock)
if (ret) {
PERROR("close");
}
if (ret) {
PERROR("close");
}
+ lttng_fd_put(LTTNG_FD_APPS, 1);
return -EINVAL;
}
lta = zmalloc(sizeof(struct ust_app));
return -EINVAL;
}
lta = zmalloc(sizeof(struct ust_app));
@@
-1450,7
+1476,7
@@
int ust_app_list_events(struct lttng_event **events)
}
memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
tmp[count].loglevel = uiter.loglevel;
}
memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
tmp[count].loglevel = uiter.loglevel;
- tmp[count].type = LTTNG_UST_TRACEPOINT;
+ tmp[count].type =
(enum lttng_event_type)
LTTNG_UST_TRACEPOINT;
tmp[count].pid = app->pid;
tmp[count].enabled = -1;
count++;
tmp[count].pid = app->pid;
tmp[count].enabled = -1;
count++;
@@
-1976,10
+2002,19
@@
int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
goto error_rcu_unlock;
}
goto error_rcu_unlock;
}
+ /* We are going to receive 2 fds, we need to reserve them. */
+ ret = lttng_fd_get(LTTNG_FD_APPS, 2);
+ if (ret < 0) {
+ ERR("Exhausted number of available FD upon stream create");
+ free(ustream);
+ goto error_rcu_unlock;
+ }
ret = ustctl_create_stream(app->sock, ua_chan->obj,
&ustream->obj);
if (ret < 0) {
/* Got all streams */
ret = ustctl_create_stream(app->sock, ua_chan->obj,
&ustream->obj);
if (ret < 0) {
/* Got all streams */
+ lttng_fd_put(LTTNG_FD_APPS, 2);
+ free(ustream);
break;
}
ustream->handle = ustream->obj->handle;
break;
}
ustream->handle = ustream->obj->handle;
@@
-1991,6
+2026,10
@@
int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
ua_chan->streams.count++);
if (ret < 0) {
PERROR("asprintf UST create stream");
ua_chan->streams.count++);
if (ret < 0) {
PERROR("asprintf UST create stream");
+ /*
+ * XXX what should we do here with the
+ * stream ?
+ */
continue;
}
DBG2("UST stream %d ready at %s", ua_chan->streams.count,
continue;
}
DBG2("UST stream %d ready at %s", ua_chan->streams.count,
@@
-2265,7
+2304,7
@@
void ust_app_global_update(struct ltt_ust_session *usess, int sock)
}
ua_sess = create_ust_app_session(usess, app);
}
ua_sess = create_ust_app_session(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == NULL
|| ua_sess == (void *) -1UL
) {
goto error;
}
goto error;
}
This page took
0.027311 seconds
and
4
git commands to generate.