Jan Kiszka : Fix remapping of global sem_heap on fork
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 36 lines · GIT version control
Module: xenomai-jki Branch: for-upstream Commit: 40e5b366397db3dde0ebde861a739dc2cd624b5a URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=40e5b366397db3dde0ebde861a739dc2cd624b5aAuthor: Jan Kiszka <[email protected]> Date: Fri Feb 12 17:40:09 2010 +0100Fix remapping of global
sem_heapon forkAs
xeno_init_sem_heapsmight 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 <[email protected]>---
src/skins/common/sem_heap.c | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-)src/skins/common/sem_heap.c +1
-1@@ -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);
src/skins/common/sem_heap.c static void unmap_sem_heap(unsigned long heap_addr, unsigned shared) · line 75
Quoted 10 lines
src/skins/common/sem_heap.c +8
-0} +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.
Signature · 1 line
Gilles.
Quoted 39 lines · Gilles Chanteperdrix
Quoted 38 lines · GIT version control
Module: xenomai-jki Branch: for-upstream Commit: 40e5b366397db3dde0ebde861a739dc2cd624b5a URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=40e5b366397db3dde0ebde861a739dc2cd624b5aAuthor: Jan Kiszka <[email protected]> Date: Fri Feb 12 17:40:09 2010 +0100Fix remapping of global
sem_heapon forkAs
xeno_init_sem_heapsmight 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 <[email protected]>---
src/skins/common/sem_heap.c | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-)src/skins/common/sem_heap.c +1
-1@@ -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); }
Quoted 12 lines
src/skins/common/sem_heap.c static void unmap_sem_heap(unsigned long heap_addr, unsigned shared) · line 75
Quoted 8 lines
src/skins/common/sem_heap.c +8
-0+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
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux