From: Pierre-Marc Fournier Date: Fri, 26 Feb 2010 22:46:23 +0000 (-0500) Subject: fork: don't switch buffer when destroying trace in child X-Git-Tag: v0.3~19 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=31d392f1a565abd0751302d8c52b9f9e695e051e;p=ust.git fork: don't switch buffer when destroying trace in child If we do switch the buffer, it switches the parent's buffer, because the both process' buffers are still the same. This is undesirable. So we add a special "drop" mode to ltt_trace_destroy. --- diff --git a/libust/tracectl.c b/libust/tracectl.c index 3cb86ed..c72d013 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -964,7 +964,7 @@ void *listener_main(void *p) DBG("trace destroy"); - result = ltt_trace_destroy(trace_name); + result = ltt_trace_destroy(trace_name, 0); if(result < 0) { ERR("ltt_trace_destroy failed"); return (void *)1; @@ -1348,7 +1348,7 @@ static void destroy_traces(void) ERR("ltt_trace_stop error"); } - result = ltt_trace_destroy("auto"); + result = ltt_trace_destroy("auto", 0); if(result == -1) { ERR("ltt_trace_destroy error"); } @@ -1453,9 +1453,10 @@ static void ust_fork(void) struct blocked_consumer *deletable_bc = NULL; int result; + /* FIXME: technically, the locks could have been taken before the fork */ DBG("ust: forking"); ltt_trace_stop("auto"); - ltt_trace_destroy("auto"); + ltt_trace_destroy("auto", 1); /* Delete all active connections */ ustcomm_close_all_connections(&ustcomm_app.server); diff --git a/libust/tracer.c b/libust/tracer.c index 52928b8..5f9aa69 100644 --- a/libust/tracer.c +++ b/libust/tracer.c @@ -784,15 +784,17 @@ traces_error: } /* Sleepable part of the destroy */ -static void __ltt_trace_destroy(struct ust_trace *trace) +static void __ltt_trace_destroy(struct ust_trace *trace, int drop) { int i; struct ust_channel *chan; - for (i = 0; i < trace->nr_channels; i++) { - chan = &trace->channels[i]; - if (chan->active) - trace->ops->finish_channel(chan); + if(!drop) { + for (i = 0; i < trace->nr_channels; i++) { + chan = &trace->channels[i]; + if (chan->active) + trace->ops->finish_channel(chan); + } } return; /* FIXME: temporary for ust */ @@ -827,7 +829,7 @@ static void __ltt_trace_destroy(struct ust_trace *trace) kref_put(&trace->kref, ltt_release_trace); } -int ltt_trace_destroy(const char *trace_name) +int ltt_trace_destroy(const char *trace_name, int drop) { int err = 0; struct ust_trace *trace; @@ -842,7 +844,7 @@ int ltt_trace_destroy(const char *trace_name) ltt_unlock_traces(); - __ltt_trace_destroy(trace); + __ltt_trace_destroy(trace, drop); //ust// put_trace_clock(); return 0; diff --git a/libust/tracer.h b/libust/tracer.h index 614d7b2..cc3974e 100644 --- a/libust/tracer.h +++ b/libust/tracer.h @@ -385,7 +385,7 @@ extern int ltt_trace_set_channel_enable(const char *trace_name, extern int ltt_trace_set_channel_overwrite(const char *trace_name, const char *channel_name, unsigned int overwrite); extern int ltt_trace_alloc(const char *trace_name); -extern int ltt_trace_destroy(const char *trace_name); +extern int ltt_trace_destroy(const char *trace_name, int drop); extern int ltt_trace_start(const char *trace_name); extern int ltt_trace_stop(const char *trace_name); diff --git a/tests/hello/hello.c b/tests/hello/hello.c index 561d92e..5db487b 100644 --- a/tests/hello/hello.c +++ b/tests/hello/hello.c @@ -63,7 +63,7 @@ int main() scanf("%*s"); ltt_trace_stop("auto"); - ltt_trace_destroy("auto"); + ltt_trace_destroy("auto", 0); DBG("TRACE STOPPED"); scanf("%*s");