From e0cd021d96628e4ccd94a56029c285b71dd959f6 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 9 Mar 2006 22:59:03 +0000 Subject: [PATCH] new ltt-usertrace : fix sem_post and dead parent git-svn-id: http://ltt.polymtl.ca/svn@1652 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt-usertrace/ltt-usertrace-fast.c | 10 +++++----- ltt-usertrace/sample-highspeed.c | 4 +++- ltt-usertrace/sample-thread-fast.c | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ltt-usertrace/ltt-usertrace-fast.c b/ltt-usertrace/ltt-usertrace-fast.c index a0544b67..6a287a1f 100644 --- a/ltt-usertrace/ltt-usertrace-fast.c +++ b/ltt-usertrace/ltt-usertrace-fast.c @@ -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(<t_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) { diff --git a/ltt-usertrace/sample-highspeed.c b/ltt-usertrace/sample-highspeed.c index 78b0c7c1..a299fed3 100644 --- a/ltt-usertrace/sample-highspeed.c +++ b/ltt-usertrace/sample-highspeed.c @@ -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!"); } diff --git a/ltt-usertrace/sample-thread-fast.c b/ltt-usertrace/sample-thread-fast.c index 6376f376..d81255fc 100644 --- a/ltt-usertrace/sample-thread-fast.c +++ b/ltt-usertrace/sample-thread-fast.c @@ -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 -- 2.34.1