X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libust%2Flttng-ust-abi.c;h=dca010c9f97353c68011eac4cab506f23d089804;hb=4eef29981ab7715d4307d591510597f9302b5c15;hp=ad582c055bb1f31e036612f8a45a9af60eaeffdc;hpb=5e96a46756a5dcd6e348afd84078b9e26438245d;p=lttng-ust.git diff --git a/libust/lttng-ust-abi.c b/libust/lttng-ust-abi.c index ad582c05..dca010c9 100644 --- a/libust/lttng-ust-abi.c +++ b/libust/lttng-ust-abi.c @@ -28,7 +28,7 @@ #include #include #include -#include "usterr_signal_safe.h" +#include #include "ust/core.h" #include "ltt-tracer.h" @@ -153,11 +153,12 @@ void objd_ref(int id) obj->u.s.f_count++; } -static -void objd_unref(int id) +int objd_unref(int id) { struct obj *obj = _objd_get(id); + if (!obj) + return -EINVAL; if (!(--obj->u.s.f_count)) { const struct objd_ops *ops = objd_ops(id); @@ -165,6 +166,7 @@ void objd_unref(int id) ops->release(id); objd_free(id); } + return 0; } static @@ -189,7 +191,6 @@ enum channel_type { METADATA_CHANNEL, }; -static int lttng_abi_create_session(void) { struct ltt_session *session; @@ -251,7 +252,7 @@ long lttng_abi_add_context(int objd, switch (context_param->ctx) { case LTTNG_UST_CONTEXT_VTID: - return lttng_add_vtid_to_ctx(ctx); + //TODO return lttng_add_vtid_to_ctx(ctx); default: return -EINVAL; } @@ -396,7 +397,12 @@ int lttng_abi_create_channel(int session_objd, return chan_objd; chan_error: - objd_unref(chan_objd); + { + int err; + + err = objd_unref(chan_objd); + assert(!err); + } objd_error: return ret; } @@ -454,17 +460,20 @@ long lttng_session_cmd(int objd, unsigned int cmd, unsigned long arg) * individual file is released). */ static -int lttng_session_release(int objd) +int lttng_release_session(int objd) { struct ltt_session *session = objd_private(objd); - if (session) + if (session) { ltt_session_destroy(session); - return 0; + return 0; + } else { + return -EINVAL; + } } static const struct objd_ops lttng_session_ops = { - .release = lttng_session_release, + .release = lttng_release_session, .cmd = lttng_session_cmd, }; @@ -527,7 +536,12 @@ int lttng_abi_create_event(int channel_objd, return event_objd; event_error: - objd_unref(event_objd); + { + int err; + + err = objd_unref(event_objd); + assert(!err); + } objd_error: return ret; } @@ -639,7 +653,7 @@ int lttng_channel_release(int objd) struct ltt_channel *channel = objd_private(objd); if (channel) - objd_unref(channel->session->objd); + return objd_unref(channel->session->objd); return 0; } @@ -694,7 +708,7 @@ int lttng_event_release(int objd) struct ltt_event *event = objd_private(objd); if (event) - objd_unref(event->chan->objd); + return objd_unref(event->chan->objd); return 0; } @@ -704,15 +718,7 @@ static const struct objd_ops lttng_event_ops = { .cmd = lttng_event_cmd, }; -void __attribute__((constructor)) lttng_ust_abi_init(void) -{ - init_usterr(); - /* TODO: initialize socket */ -} - -static -void __attribute__((destructor)) lttng_ust_abi_exit(void) +void lttng_ust_abi_exit(void) { - /* TODO: teardown socket */ objd_table_destroy(); }