From: David Goulet Date: Fri, 23 May 2014 14:32:09 +0000 (-0400) Subject: Fix: deny overwrite mode and num subbuf less than 2 X-Git-Tag: v2.5.0-rc1~21 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=33fbd46910b681a74b2493cff8c86979ec35ccc9;p=lttng-tools.git Fix: deny overwrite mode and num subbuf less than 2 Also fixed in UST and modules with commit: (modules) 5140d2b3070f211e6d8a0ad7cb0a190e8b6f3e28 (ust) 3d8e9399b2fb9000b3b55e488a7d04184b5bb56e Fixes #793 Signed-off-by: David Goulet --- diff --git a/doc/man/lttng.1 b/doc/man/lttng.1 index 483df2aef..09c77d1d3 100644 --- a/doc/man/lttng.1 +++ b/doc/man/lttng.1 @@ -402,7 +402,8 @@ Apply to the user-space tracer Discard event when subbuffers are full (default) .TP .BR "\-\-overwrite" -Flight recorder mode : overwrites events when subbuffers are full +Flight recorder mode: overwrites events when subbuffers are full. The +number of subbuffer must be 2 or more. .TP .BR "\-\-subbuf-size SIZE" Subbuffer size in bytes {+k,+M,+G}. diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index eb516d3b1..2536dc72d 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -933,6 +933,16 @@ int cmd_enable_channel(struct ltt_session *session, attr->attr.switch_timer_interval = 0; } + /* + * The ringbuffer (both in user space and kernel) behave badly in overwrite + * mode and with less than 2 subbuf so block it right away and send back an + * invalid attribute error. + */ + if (attr->attr.overwrite && attr->attr.num_subbuf < 2) { + ret = LTTNG_ERR_INVALID; + goto error; + } + switch (domain->type) { case LTTNG_DOMAIN_KERNEL: {