signal fix
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 2 Feb 2007 05:30:28 +0000 (05:30 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 2 Feb 2007 05:30:28 +0000 (05:30 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2353 04897980-b3bd-0310-b5e0-8ef037075253

ltt-usertrace/ltt/ltt-usertrace-fast.h

index b90a100629b43d221f156cb1ef061a1eaeaaad23..7c295e4b38f932d9692214220a1244738556fce9 100644 (file)
@@ -366,6 +366,16 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot(
        int consumed_old, consumed_new;
        int commit_count, reserve_count;
        int ret;
+       sigset_t oldset, set;
+
+       /* sem_wait is not signal safe. Disable signals around it. */
+
+       /* Disable signals */
+       ret = sigfillset(&set);
+       if(ret) perror("LTT Error in sigfillset\n"); 
+       
+       ret = pthread_sigmask(SIG_BLOCK, &set, &oldset);
+       if(ret) perror("LTT Error in pthread_sigmask\n");
 
        do {
                offset_old = atomic_read(&ltt_buf->offset);
@@ -411,22 +421,9 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot(
                                //if((SUBBUF_TRUNC(offset_begin, ltt_buf) 
                                //                              - SUBBUF_TRUNC(atomic_read(&ltt_buf->consumed), ltt_buf))
                                //                                      >= ltt_buf->alloc_size) {
-                               /* sem_wait is not signal safe. Disable signals around it. */
                                {
-                                       sigset_t oldset, set;
-
-                                       /* Disable signals */
-                                       ret = sigfillset(&set);
-                                       if(ret) perror("LTT Error in sigfillset\n"); 
-                                       
-                                       ret = pthread_sigmask(SIG_BLOCK, &set, &oldset);
-                                       if(ret) perror("LTT Error in pthread_sigmask\n");
-
                                        sem_wait(&ltt_buf->writer_sem);
 
-                                       /* Enable signals */
-                                       ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
-                                       if(ret) perror("LTT Error in pthread_sigmask\n");
                                }
 
                                        /* go on with the write */
@@ -466,6 +463,9 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot(
        } while(atomic_cmpxchg(&ltt_buf->offset, offset_old, offset_end)
                                                        != offset_old);
 
+       /* Enable signals */
+       ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+       if(ret) perror("LTT Error in pthread_sigmask\n");
 
        /* Push the reader if necessary */
        do {
This page took 0.024572 seconds and 4 git commands to generate.