sem wait signal safety
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 17:49:43 +0000 (17:49 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 17:49:43 +0000 (17:49 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1628 04897980-b3bd-0310-b5e0-8ef037075253

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

index 318eff6a0df7f29730addd11669cb2437e5c02e9..45b8b6c0cf805abbd24fa4de3dcdbba331068fa5 100644 (file)
@@ -17,6 +17,7 @@
 #include <syscall.h>
 #include <asm/timex.h>
 #include <semaphore.h>
+#include <signal.h>
 
 #include <ltt/ltt-facility-id-user_generic.h>
 #include <ltt/ltt-generic.h>
@@ -410,7 +411,24 @@ 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(&ltt_buf->writer_sem);
+                               /* 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 */
 
                                //} else {
This page took 0.024575 seconds and 4 git commands to generate.