From: Mathieu Desnoyers Date: Wed, 8 Dec 2010 19:41:36 +0000 (-0500) Subject: ABI runtime fixes X-Git-Tag: v2.0-pre1~201 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f3d01b96c9189afbeb273ad7382eb89ee70a0e61;p=lttng-modules.git ABI runtime fixes Signed-off-by: Mathieu Desnoyers --- diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index f9b7e9b0..d136a779 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -141,7 +141,7 @@ int lttng_abi_create_channel(struct file *session_file, chan_param.switch_timer_interval, chan_param.read_timer_interval); if (!chan) { - ret = -ENOMEM; + ret = -EINVAL; goto chan_error; } chan->file = chan_file; @@ -412,7 +412,7 @@ int __init ltt_debugfs_abi_init(void) int ret = 0; lttng_dentry = debugfs_create_file("lttng", S_IWUSR, NULL, NULL, - <tng_session_fops); + <tng_fops); if (IS_ERR(lttng_dentry) || !lttng_dentry) { printk(KERN_ERR "Error creating LTTng control file\n"); ret = -ENOMEM; diff --git a/ltt-events.c b/ltt-events.c index f3f7ab78..60317068 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -32,10 +32,11 @@ struct ltt_session *ltt_session_create(void) struct ltt_session *session; mutex_lock(&sessions_mutex); - session = kmalloc(sizeof(struct ltt_session), GFP_KERNEL); + session = kzalloc(sizeof(struct ltt_session), GFP_KERNEL); if (!session) return NULL; INIT_LIST_HEAD(&session->chan); + INIT_LIST_HEAD(&session->events); list_add(&session->list, &sessions); mutex_unlock(&sessions_mutex); return session; @@ -90,6 +91,17 @@ end: return ret; } +static struct ltt_transport *ltt_transport_find(char *name) +{ + struct ltt_transport *transport; + + list_for_each_entry(transport, <t_transport_list, node) { + if (!strcmp(transport->name, name)) + return transport; + } + return NULL; +} + struct ltt_channel *ltt_channel_create(struct ltt_session *session, int overwrite, void *buf_addr, size_t subbuf_size, size_t num_subbuf, @@ -97,22 +109,23 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, unsigned int read_timer_interval) { struct ltt_channel *chan; - struct ltt_transport *transport = NULL, *tran_iter; + struct ltt_transport *transport; char *transport_name; mutex_lock(&sessions_mutex); - if (session->active) + if (session->active) { + printk(KERN_WARNING "LTTng refusing to add channel to active session\n"); goto active; /* Refuse to add channel to active session */ - transport_name = overwrite ? "relay-overwrite" : "relay-discard"; - list_for_each_entry(tran_iter, <t_transport_list, node) { - if (!strcmp(tran_iter->name, transport_name)) { - transport = tran_iter; - break; - } } - if (!transport) + transport_name = overwrite ? "relay-overwrite" : "relay-discard"; + transport = ltt_transport_find(transport_name); + if (!transport) { + printk(KERN_WARNING "LTTng transport %s not found\n", + transport_name); goto notransport; - chan = kmalloc(sizeof(struct ltt_channel), GFP_KERNEL); + } + printk("got transport\n"); + chan = kzalloc(sizeof(struct ltt_channel), GFP_KERNEL); if (!chan) goto nomem; chan->session = session; @@ -120,11 +133,16 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, chan->chan = transport->ops.channel_create("[lttng]", session, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, read_timer_interval); + printk("chan create %p\n", chan->chan); + if (!chan->chan) + goto create_error; chan->ops = &transport->ops; list_add(&chan->list, &session->chan); mutex_unlock(&sessions_mutex); return chan; +create_error: + kfree(chan); nomem: notransport: active: