From: compudj Date: Thu, 9 Mar 2006 17:49:43 +0000 (+0000) Subject: sem wait signal safety X-Git-Tag: v0.12.20~1861 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=be5cc22c25f72553656aea2665a070b09e05ffaa;p=lttv.git sem wait signal safety git-svn-id: http://ltt.polymtl.ca/svn@1628 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/usertrace-fast/ltt/ltt-usertrace-fast.h b/usertrace-fast/ltt/ltt-usertrace-fast.h index 318eff6a..45b8b6c0 100644 --- a/usertrace-fast/ltt/ltt-usertrace-fast.h +++ b/usertrace-fast/ltt/ltt-usertrace-fast.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -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(<t_buf->consumed), ltt_buf)) // >= ltt_buf->alloc_size) { - sem_wait(<t_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(<t_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 {