All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Xenomai-core] [Xenomai-git] Jan Kiszka : Fix remapping of global sem_heap on fork
       [not found] <E1NfybE-0003dg-9e@domain.hid>
@ 2010-02-12 17:23 ` Gilles Chanteperdrix
  2010-02-12 17:41   ` Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: Gilles Chanteperdrix @ 2010-02-12 17:23 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai core

GIT version control wrote:
> Module: xenomai-jki
> Branch: for-upstream
> Commit: 40e5b366397db3dde0ebde861a739dc2cd624b5a
> URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=40e5b366397db3dde0ebde861a739dc2cd624b5a
> 
> Author: Jan Kiszka <jan.kiszka@domain.hid>
> Date:   Fri Feb 12 17:40:09 2010 +0100
> 
> Fix remapping of global sem_heap on fork
> 
> As xeno_init_sem_heaps might be called multiple times even without fork,
> we must not remap the global heap here. Register an atfork handler
> instead that handles this case and simple reject multiple heap creation
> requests for the same process.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
> 
> ---
> 
>  src/skins/common/sem_heap.c |   29 ++++++++++++++++++-----------
>  1 files changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/src/skins/common/sem_heap.c b/src/skins/common/sem_heap.c
> index 89f325a..12b256f 100644
> --- a/src/skins/common/sem_heap.c
> +++ b/src/skins/common/sem_heap.c
> @@ -1,6 +1,6 @@
>  #include <stdio.h>
>  #include <stdlib.h>
> -
> +#include <pthread.h>
>  #include <unistd.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> @@ -65,24 +65,31 @@ static void unmap_sem_heap(unsigned long heap_addr, unsigned shared)
>  	munmap((void *) heap_addr, hinfo.size);
>  }
>  
> +static void remap_on_fork(void)
> +{
> +	unmap_sem_heap(xeno_sem_heap[0], 0);
> +
> +	if (xeno_sem_heap[0] == (unsigned long) MAP_FAILED) {
> +		perror("Xenomai: mmap(local sem heap)");
> +		exit(EXIT_FAILURE);
> +	}

Looks bogus to me. Where do the remap occur ?
Looks like your test case does not try forking.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Xenomai-core] [Xenomai-git] Jan Kiszka : Fix remapping of global sem_heap on fork
  2010-02-12 17:23 ` [Xenomai-core] [Xenomai-git] Jan Kiszka : Fix remapping of global sem_heap on fork Gilles Chanteperdrix
@ 2010-02-12 17:41   ` Jan Kiszka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2010-02-12 17:41 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai core

Gilles Chanteperdrix wrote:
> GIT version control wrote:
>> Module: xenomai-jki
>> Branch: for-upstream
>> Commit: 40e5b366397db3dde0ebde861a739dc2cd624b5a
>> URL:    http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=40e5b366397db3dde0ebde861a739dc2cd624b5a
>>
>> Author: Jan Kiszka <jan.kiszka@domain.hid>
>> Date:   Fri Feb 12 17:40:09 2010 +0100
>>
>> Fix remapping of global sem_heap on fork
>>
>> As xeno_init_sem_heaps might be called multiple times even without fork,
>> we must not remap the global heap here. Register an atfork handler
>> instead that handles this case and simple reject multiple heap creation
>> requests for the same process.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
>>
>> ---
>>
>>  src/skins/common/sem_heap.c |   29 ++++++++++++++++++-----------
>>  1 files changed, 18 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/skins/common/sem_heap.c b/src/skins/common/sem_heap.c
>> index 89f325a..12b256f 100644
>> --- a/src/skins/common/sem_heap.c
>> +++ b/src/skins/common/sem_heap.c
>> @@ -1,6 +1,6 @@
>>  #include <stdio.h>
>>  #include <stdlib.h>
>> -
>> +#include <pthread.h>
>>  #include <unistd.h>
>>  #include <sys/types.h>
>>  #include <sys/stat.h>
>> @@ -65,24 +65,31 @@ static void unmap_sem_heap(unsigned long heap_addr, unsigned shared)
>>  	munmap((void *) heap_addr, hinfo.size);
>>  }
>>  
>> +static void remap_on_fork(void)
>> +{
>> +	unmap_sem_heap(xeno_sem_heap[0], 0);
>> +
>> +	if (xeno_sem_heap[0] == (unsigned long) MAP_FAILED) {
>> +		perror("Xenomai: mmap(local sem heap)");
>> +		exit(EXIT_FAILURE);
>> +	}
> 
> Looks bogus to me. Where do the remap occur ?
> Looks like your test case does not try forking.
> 

Yep, copy&paste error. Fixed.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-12 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1NfybE-0003dg-9e@domain.hid>
2010-02-12 17:23 ` [Xenomai-core] [Xenomai-git] Jan Kiszka : Fix remapping of global sem_heap on fork Gilles Chanteperdrix
2010-02-12 17:41   ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.