fork: don't switch buffer when destroying trace in child
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 26 Feb 2010 22:46:23 +0000 (17:46 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 26 Feb 2010 22:46:23 +0000 (17:46 -0500)
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.

libust/tracectl.c
libust/tracer.c
libust/tracer.h
tests/hello/hello.c

index 3cb86edc80180f535e8a5773d8413ee11032db64..c72d013d7535a5539960e4d111ad24b39bcc6e54 100644 (file)
@@ -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);
 
index 52928b836ba290c9d67d1ce45cc63377b32ba693..5f9aa69ffe2d8531f1c88bed35eb910b82b709ae 100644 (file)
@@ -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;
index 614d7b2c2877b32703296ec40cbe9506017cf551..cc3974e2a9d45ef0febc077b153ffa7637fe2ad3 100644 (file)
@@ -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);
 
index 561d92e464d7f00871a97f42265a190a4c0ee141..5db487b05a1503040865102e34565b8427f0a932 100644 (file)
@@ -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");
This page took 0.027364 seconds and 4 git commands to generate.