From: iripoll Date: Wed, 27 Feb 2008 11:59:05 +0000 (+0000) Subject: FOSA-PaRTiKle: conditional compilation to free used signals in long jumps X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/fosa.git/commitdiff_plain/c320e7dd57b914c508ac7f01bb95d294481bcfe1 FOSA-PaRTiKle: conditional compilation to free used signals in long jumps git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1029 35b4ef3e-fd22-0410-ab77-dab3279adceb --- diff --git a/src_partikle/fosa_long_jump.c b/src_partikle/fosa_long_jump.c index 6ad5407..4462074 100644 --- a/src_partikle/fosa_long_jump.c +++ b/src_partikle/fosa_long_jump.c @@ -75,6 +75,7 @@ enum { int jmp_used_signals [LONGJMP_NSIG] = {[0 ... (LONGJMP_NSIG - 1)] = 0}; + int fosa_long_jump_save_context (fosa_long_jump_context_t * context) { @@ -86,12 +87,15 @@ int fosa_long_jump_save_context context -> jmp_hasexecuted = false; if (setjmp (context -> jmp_context) == LONGJMP_MAGIC) { - context -> jmp_hasexecuted = true; +#ifndef CONFIG_LONGJUMP_FREE_SIGNALS pthread_sigmask (SIG_SETMASK, &(context -> jmp_sigmask), NULL); +#endif + context -> jmp_hasexecuted = true; } return 0; } + int fosa_long_jump_was_performed (const fosa_long_jump_context_t * context, int * jumped) { @@ -102,13 +106,32 @@ int fosa_long_jump_was_performed return 0; } + void jmp_handler (int signo, siginfo_t *info, void *context) { fosa_long_jump_context_t *jmp_info = (fosa_long_jump_context_t *) info -> si_value.sival_ptr; + sigset_t set; + +#ifdef CONFIG_LONGJUMP_FREE_SIGNALS + // Restore the signal mask beofre the context save + pthread_sigmask (SIG_SETMASK, &(context -> jmp_sigmask), NULL); + + // Free this signal + sigemptyset (&set); + sigaddset (&set, signo); + pthread_sigmask (SIG_BLOCK, &sigmask, NULL); + + pthread_mutex_lock (); + jmp_used_signals [signo] = 0; + pthread_mutex_unlock (); +#endif + + // Restore the saved context longjmp (jmp_info -> jmp_context, LONGJMP_MAGIC); return; } + int fosa_long_jump_install_handler (fosa_signal_t *signal, fosa_thread_id_t *handler) { @@ -141,5 +164,4 @@ int fosa_long_jump_install_handler return 0; } - #endif /* CONFIG_LONGJUMP */