#include <sys/types.h>
#include <unistd.h>
#include <urcu/compiler.h>
+#include <lttng/ust-error.h>
#include <common/common.h>
#include <common/sessiond-comm/sessiond-comm.h>
ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
&ua_event->obj);
if (ret < 0) {
- if (ret == -EEXIST || ret == -EPERM) {
- ret = 0;
- goto error;
- }
ERR("Error ustctl create event %s for app pid: %d with ret %d",
ua_event->attr.name, app->pid, ret);
goto error;
* just created it.
*/
switch (ret) {
- case -EPERM:
+ case -LTTNG_UST_ERR_PERM:
/* Code flow problem */
assert(0);
- case -EEXIST:
+ case -LTTNG_UST_ERR_EXIST:
/* It's OK for our use case. */
ret = 0;
break;
ret = create_ust_channel(app, ua_sess, ua_chan);
if (ret < 0) {
/* Not found previously means that it does not exist on the tracer */
- assert(ret != -EEXIST);
+ assert(ret != -LTTNG_UST_ERR_EXIST);
goto error;
}
ret = create_ust_event(app, ua_sess, ua_chan, ua_event);
if (ret < 0) {
/* Not found previously means that it does not exist on the tracer */
- assert(ret != -EEXIST);
+ assert(ret == -LTTNG_UST_ERR_EXIST);
goto error;
}
/* Assign second node for deletion */
iter.iter.node = <a->pid_n.node;
+ /*
+ * Ignore return value since the node might have been removed before by an
+ * add replace during app registration because the PID can be reassigned by
+ * the OS.
+ */
ret = lttng_ht_del(ust_app_ht, &iter);
- assert(!ret);
+ if (ret) {
+ DBG3("Unregister app by PID %d failed. This can happen on pid reuse",
+ lta->pid);
+ }
/* Free memory */
call_rcu(<a->pid_n.head, delete_ust_app_rcu);
}
while ((ret = ustctl_tracepoint_list_get(app->sock, handle,
- &uiter)) != -ENOENT) {
+ &uiter)) != -LTTNG_UST_ERR_NOENT) {
health_code_update(&health_thread_cmd);
if (count >= nbmem) {
/* In case the realloc fails, we free the memory */
}
while ((ret = ustctl_tracepoint_field_list_get(app->sock, handle,
- &uiter)) != -ENOENT) {
+ &uiter)) != -LTTNG_UST_ERR_NOENT) {
health_code_update(&health_thread_cmd);
if (count >= nbmem) {
/* In case the realloc fails, we free the memory */
int ust_app_create_channel_glb(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan)
{
+ int ret = 0;
struct lttng_ht_iter iter;
struct ust_app *app;
struct ust_app_session *ua_sess;
ua_sess = create_ust_app_session(usess, app);
if (ua_sess == NULL) {
/* The malloc() failed. */
+ ret = -1;
goto error;
} else if (ua_sess == (void *) -1UL) {
/* The application's socket is not valid. Contiuing */
+ ret = -1;
continue;
}
ua_chan = create_ust_app_channel(ua_sess, uchan, app);
if (ua_chan == NULL) {
/* Major problem here and it's maybe the tracer or malloc() */
+ ret = -1;
goto error;
}
}
rcu_read_unlock();
- return 0;
-
error:
- return -1;
+ return ret;
}
/*
ret = create_ust_app_event(ua_sess, ua_chan, uevent, app);
if (ret < 0) {
- if (ret != -EEXIST) {
+ if (ret != -LTTNG_UST_ERR_EXIST) {
/* Possible value at this point: -ENOMEM. If so, we stop! */
break;
}
}
ua_sess = create_ust_app_session(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == NULL || ua_sess == (void *) -1UL) {
+ /* Tracer is gone for this session and has been freed */
goto error;
}