new ltt-usertrace : fix sem_post and dead parent
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 22:59:03 +0000 (22:59 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 22:59:03 +0000 (22:59 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1652 04897980-b3bd-0310-b5e0-8ef037075253

ltt-usertrace/ltt-usertrace-fast.c
ltt-usertrace/sample-highspeed.c
ltt-usertrace/sample-thread-fast.c

index a0544b67d57b407e7ddc985fa317346ae3a3d432..6a287a1f73f554b77e390631a61a2e28369e014f 100644 (file)
@@ -320,6 +320,8 @@ static inline int ltt_buffer_put(struct ltt_buf *ltt_buf,
                 * It can also happen if this is a buffer we never got. */
                return -EIO;
        } else {
+               if(traced_pid == 0 || parent_exited) return 0;
+
                ret = sem_post(&ltt_buf->writer_sem);
                if(ret < 0) {
                        printf("error in sem_post");
@@ -378,7 +380,7 @@ static void ltt_usertrace_fast_daemon(struct ltt_trace_info *shared_trace_info,
 {
        struct sigaction act;
        int ret;
-       int fd_process;
+       int fd_process = -1;
        char outfile_name[PATH_MAX];
        char identifier_name[PATH_MAX];
 
@@ -429,7 +431,6 @@ static void ltt_usertrace_fast_daemon(struct ltt_trace_info *shared_trace_info,
        if(ret != -1) {
                perror("LTT Error in sigsuspend\n");
        }
-       if((traced_pid == 0) || parent_exited) goto dead_parent;
 
 #ifndef LTT_NULL_OUTPUT_TEST
        fd_process = creat(outfile_name, 0644);
@@ -459,7 +460,6 @@ static void ltt_usertrace_fast_daemon(struct ltt_trace_info *shared_trace_info,
                        perror("LTT Error in sigsuspend\n");
                }
        }
-dead_parent:
        /* The parent thread is dead and we have finished with the buffer */
 
        /* Buffer force switch (flush). Using FLUSH instead of ACTIVE because we know
@@ -469,8 +469,8 @@ dead_parent:
                ret = read_subbuffer(&shared_trace_info->channel.process, fd_process);
        } while(ret == 0);
 
-
-       close(fd_process);
+       if(fd_process != -1)
+               close(fd_process);
        
        ret = sem_destroy(&shared_trace_info->channel.process.writer_sem);
        if(ret < 0) {
index 78b0c7c19a06b09cbd924ec759e2ec8df4b8c56a..a299fed371a4f597228d2766765c4f7596d01b73 100644 (file)
@@ -13,7 +13,9 @@ int main(int argc, char **argv)
        printf("Abort with CTRL-C or it will quickly fill up your disk.\n");
        printf("See the result file in /tmp/ltt-usertrace.\n");
 
-       while(1) {
+       int i;
+       //while(1) {
+       for(i=0; i<100000; i++) {
                trace_user_generic_string("Running fast!");
        }
        
index 6376f37675894ae81cb1f03fe47f1a5996805de2..d81255fc0d5c3c695dee1082032a7bf29b6493ca 100644 (file)
@@ -17,7 +17,7 @@ void *thr1(void *arg)
        printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
 
        for(i=0; i<100000; i++) {
-               trace_user_generic_string("Hello world! Have a nice day.");
+//             trace_user_generic_string("Hello world! Have a nice day.");
        }
        pthread_exit((void*)1);
 }
@@ -31,7 +31,7 @@ void *thr2(void *arg)
        printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
 
        for(i=0; i<100000; i++) {
-//             trace_user_generic_string("Hello world! Have a nice day.");
+               trace_user_generic_string("Hello world! Have a nice day.");
        }
        /* This thread is a bad citizen : returning like this will cause its cancel
         * routines not to be executed. This is still detected by the tracer, but only
This page took 0.028126 seconds and 4 git commands to generate.