Ticket #2228: 0004-Posix-signals-1-Put-siginfo-always-into-queue.patch

File 0004-Posix-signals-1-Put-siginfo-always-into-queue.patch, 4.3 KB (added by Daniel Krüger, on Dec 17, 2014 at 12:44:43 PM)
  • cpukit/posix/src/killinfo.c

    From c466a655048690ca650e3bc6008b1e0090d89cf4 Mon Sep 17 00:00:00 2001
    From: Daniel Krueger <daniel.krueger@systec-electronic.com>
    Date: Tue, 9 Dec 2014 16:10:09 +0000
    Subject: [PATCH 4/6] Posix signals [1]: Put siginfo always into queue
    
    even if there is no sigaction registered to this signal. This change
    enables multiple timer signals (with the very same signal number) to
    be queued and fetched with sigtimedwait().
    
    Signed-off-by: Daniel Krueger <daniel.krueger@systec-electronic.com>
    ---
     cpukit/posix/src/killinfo.c                   |   19 ++++++--------
     cpukit/posix/src/psignalclearprocesssignals.c |    6 ++---
     cpukit/posix/src/psignalclearsignals.c        |   35 +++++++++++--------------
     3 files changed, 26 insertions(+), 34 deletions(-)
    
    diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c
    index 5d3dded..0e464ea 100644
    a b post_process_signal: 
    336336   */
    337337  _POSIX_signals_Set_process_signals( mask );
    338338
    339   if ( _POSIX_signals_Vectors[ sig ].sa_flags == SA_SIGINFO ) {
    340 
    341     psiginfo = (POSIX_signals_Siginfo_node *)
    342                _Chain_Get( &_POSIX_signals_Inactive_siginfo );
    343     if ( !psiginfo ) {
    344       _Thread_Enable_dispatch();
    345       rtems_set_errno_and_return_minus_one( EAGAIN );
    346     }
     339  psiginfo = (POSIX_signals_Siginfo_node *)
     340             _Chain_Get( &_POSIX_signals_Inactive_siginfo );
     341  if ( !psiginfo ) {
     342    _Thread_Enable_dispatch();
     343    rtems_set_errno_and_return_minus_one( EAGAIN );
     344  }
    347345
    348     psiginfo->Info = *siginfo;
     346  psiginfo->Info = *siginfo;
    349347
    350     _Chain_Append( &_POSIX_signals_Siginfo[ sig ], &psiginfo->Node );
    351   }
     348  _Chain_Append( &_POSIX_signals_Siginfo[ sig ], &psiginfo->Node );
    352349
    353350  DEBUG_STEP("\n");
    354351  _Thread_Enable_dispatch();
  • cpukit/posix/src/psignalclearprocesssignals.c

    diff --git a/cpukit/posix/src/psignalclearprocesssignals.c b/cpukit/posix/src/psignalclearprocesssignals.c
    index 2ec1bbe..037d7f6 100644
    a b void _POSIX_signals_Clear_process_signals( 
    3333  clear_signal = true;
    3434  mask         = signo_to_mask( signo );
    3535
    36   if ( _POSIX_signals_Vectors[ signo ].sa_flags == SA_SIGINFO ) {
    37     if ( !_Chain_Is_empty( &_POSIX_signals_Siginfo[ signo ] ) )
    38       clear_signal = false;
    39   }
     36  if ( !_Chain_Is_empty( &_POSIX_signals_Siginfo[ signo ] ) )
     37    clear_signal = false;
    4038
    4139  if ( clear_signal ) {
    4240    _POSIX_signals_Pending &= ~mask;
  • cpukit/posix/src/psignalclearsignals.c

    diff --git a/cpukit/posix/src/psignalclearsignals.c b/cpukit/posix/src/psignalclearsignals.c
    index 8999145..8b82d69 100644
    a b bool _POSIX_signals_Clear_signals( 
    7474
    7575    if ( is_global ) {
    7676       if ( mask & (_POSIX_signals_Pending & signals_blocked) ) {
    77          if ( _POSIX_signals_Vectors[ signo ].sa_flags == SA_SIGINFO ) {
    78            psiginfo = (POSIX_signals_Siginfo_node *)
    79              _Chain_Get_unprotected( &_POSIX_signals_Siginfo[ signo ] );
    80            _POSIX_signals_Clear_process_signals( signo );
    81            /*
    82             *  It may be impossible to get here with an empty chain
    83             *  BUT until that is proven we need to be defensive and
    84             *  protect against it.
    85             */
    86            if ( psiginfo ) {
    87              *info = psiginfo->Info;
    88              _Chain_Append_unprotected(
    89                &_POSIX_signals_Inactive_siginfo,
    90                &psiginfo->Node
    91              );
    92            } else
    93              do_callout = false;
    94          }
     77         psiginfo = (POSIX_signals_Siginfo_node *)
     78           _Chain_Get_unprotected( &_POSIX_signals_Siginfo[ signo ] );
    9579         _POSIX_signals_Clear_process_signals( signo );
    96          do_callout = true;
     80         /*
     81          *  It may be impossible to get here with an empty chain
     82          *  BUT until that is proven we need to be defensive and
     83          *  protect against it.
     84          */
     85         if ( psiginfo ) {
     86           *info = psiginfo->Info;
     87           _Chain_Append_unprotected(
     88             &_POSIX_signals_Inactive_siginfo,
     89             &psiginfo->Node
     90           );
     91           do_callout = true;
     92         } else
     93           do_callout = false;
    9794       }
    9895    } else {
    9996      if ( mask & (api->signals_pending & signals_blocked) ) {