diff mbox

[v2] Fix signal handling when io-thread is disabled

Message ID 1308060336-608-1-git-send-email-cerbere@gmail.com
State New
Headers show

Commit Message

Alexandre Raymond June 14, 2011, 2:05 p.m. UTC
Changes since v1:
- take pthread_sigmask() out of the ifdef as it is now common
to both parts.

This fix effectively blocks, in the main thread, the signals handled
by signalfd or the compatibility signal thread.

This way, such signals are received synchronously in the main thread
through sigfd_handler() instead of triggering the signal handler
directly, asynchronously.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 cpus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Jan Kiszka June 14, 2011, 4:47 p.m. UTC | #1
On 2011-06-14 16:05, Alexandre Raymond wrote:
> Changes since v1:
> - take pthread_sigmask() out of the ifdef as it is now common
> to both parts.
> 
> This fix effectively blocks, in the main thread, the signals handled
> by signalfd or the compatibility signal thread.
> 
> This way, such signals are received synchronously in the main thread
> through sigfd_handler() instead of triggering the signal handler
> directly, asynchronously.
> 
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
> ---
>  cpus.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 4ab76f0..18a1522 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -399,7 +399,6 @@ static int qemu_signal_init(void)
>      sigaddset(&set, SIGALRM);
>      sigaddset(&set, SIG_IPI);
>      sigaddset(&set, SIGBUS);
> -    pthread_sigmask(SIG_BLOCK, &set, NULL);
>  #else
>      sigemptyset(&set);
>      sigaddset(&set, SIGBUS);
> @@ -412,6 +411,7 @@ static int qemu_signal_init(void)
>          sigaddset(&set, SIGALRM);
>      }
>  #endif
> +    pthread_sigmask(SIG_BLOCK, &set, NULL);
>  
>      sigfd = qemu_signalfd(&set);
>      if (sigfd == -1) {

Acked-by: Jan Kiszka <jan.kiszka@siemens.com>

Thanks,
Jan
Alexandre Raymond July 9, 2011, 2:30 a.m. UTC | #2
ping?

On Tue, Jun 14, 2011 at 12:47 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> On 2011-06-14 16:05, Alexandre Raymond wrote:
>> Changes since v1:
>> - take pthread_sigmask() out of the ifdef as it is now common
>> to both parts.
>>
>> This fix effectively blocks, in the main thread, the signals handled
>> by signalfd or the compatibility signal thread.
>>
>> This way, such signals are received synchronously in the main thread
>> through sigfd_handler() instead of triggering the signal handler
>> directly, asynchronously.
>>
>> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
>> ---
>>  cpus.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/cpus.c b/cpus.c
>> index 4ab76f0..18a1522 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -399,7 +399,6 @@ static int qemu_signal_init(void)
>>      sigaddset(&set, SIGALRM);
>>      sigaddset(&set, SIG_IPI);
>>      sigaddset(&set, SIGBUS);
>> -    pthread_sigmask(SIG_BLOCK, &set, NULL);
>>  #else
>>      sigemptyset(&set);
>>      sigaddset(&set, SIGBUS);
>> @@ -412,6 +411,7 @@ static int qemu_signal_init(void)
>>          sigaddset(&set, SIGALRM);
>>      }
>>  #endif
>> +    pthread_sigmask(SIG_BLOCK, &set, NULL);
>>
>>      sigfd = qemu_signalfd(&set);
>>      if (sigfd == -1) {
>
> Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
>
> Thanks,
> Jan
>
> --
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux
>
Blue Swirl July 16, 2011, 7:45 p.m. UTC | #3
Thanks, applied.

On Sat, Jul 9, 2011 at 5:30 AM, Alexandre Raymond <cerbere@gmail.com> wrote:
> ping?
>
> On Tue, Jun 14, 2011 at 12:47 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>> On 2011-06-14 16:05, Alexandre Raymond wrote:
>>> Changes since v1:
>>> - take pthread_sigmask() out of the ifdef as it is now common
>>> to both parts.
>>>
>>> This fix effectively blocks, in the main thread, the signals handled
>>> by signalfd or the compatibility signal thread.
>>>
>>> This way, such signals are received synchronously in the main thread
>>> through sigfd_handler() instead of triggering the signal handler
>>> directly, asynchronously.
>>>
>>> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
>>> ---
>>>  cpus.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/cpus.c b/cpus.c
>>> index 4ab76f0..18a1522 100644
>>> --- a/cpus.c
>>> +++ b/cpus.c
>>> @@ -399,7 +399,6 @@ static int qemu_signal_init(void)
>>>      sigaddset(&set, SIGALRM);
>>>      sigaddset(&set, SIG_IPI);
>>>      sigaddset(&set, SIGBUS);
>>> -    pthread_sigmask(SIG_BLOCK, &set, NULL);
>>>  #else
>>>      sigemptyset(&set);
>>>      sigaddset(&set, SIGBUS);
>>> @@ -412,6 +411,7 @@ static int qemu_signal_init(void)
>>>          sigaddset(&set, SIGALRM);
>>>      }
>>>  #endif
>>> +    pthread_sigmask(SIG_BLOCK, &set, NULL);
>>>
>>>      sigfd = qemu_signalfd(&set);
>>>      if (sigfd == -1) {
>>
>> Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> Thanks,
>> Jan
>>
>> --
>> Siemens AG, Corporate Technology, CT T DE IT 1
>> Corporate Competence Center Embedded Linux
>>
>
>
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index 4ab76f0..18a1522 100644
--- a/cpus.c
+++ b/cpus.c
@@ -399,7 +399,6 @@  static int qemu_signal_init(void)
     sigaddset(&set, SIGALRM);
     sigaddset(&set, SIG_IPI);
     sigaddset(&set, SIGBUS);
-    pthread_sigmask(SIG_BLOCK, &set, NULL);
 #else
     sigemptyset(&set);
     sigaddset(&set, SIGBUS);
@@ -412,6 +411,7 @@  static int qemu_signal_init(void)
         sigaddset(&set, SIGALRM);
     }
 #endif
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
 
     sigfd = qemu_signalfd(&set);
     if (sigfd == -1) {