diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-04 09:32:00 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-19 12:00:44 +0200 |
commit | 776a50c47a1751bf5c5957eab446d33fd50ebeae (patch) | |
tree | 6c7b1f670f8d00297ff11d5a66bcf6def81093ac /cpukit/libcsupport/src/privateenv.c | |
parent | libcsupport: Fix umask() locking (diff) | |
download | rtems-776a50c47a1751bf5c5957eab446d33fd50ebeae.tar.bz2 |
Filesystem: Thread life protection for env changes
Diffstat (limited to 'cpukit/libcsupport/src/privateenv.c')
-rw-r--r-- | cpukit/libcsupport/src/privateenv.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/cpukit/libcsupport/src/privateenv.c b/cpukit/libcsupport/src/privateenv.c index 57177453c4..29821e4045 100644 --- a/cpukit/libcsupport/src/privateenv.c +++ b/cpukit/libcsupport/src/privateenv.c @@ -23,7 +23,7 @@ #include <stdlib.h> #include <rtems/libio_.h> -#include <rtems/score/threaddispatch.h> +#include <rtems/score/threadimpl.h> /** * Instantiate a private user environment for the calling thread. @@ -50,13 +50,6 @@ void rtems_libio_free_user_env(void *arg) } } -static void free_user_env_protected(rtems_user_env_t *env) -{ - _Thread_Disable_dispatch(); - rtems_libio_free_user_env(env); - _Thread_Enable_dispatch(); -} - rtems_status_code rtems_libio_set_private_env(void) { rtems_status_code sc = RTEMS_SUCCESSFUL; @@ -64,6 +57,7 @@ rtems_status_code rtems_libio_set_private_env(void) bool uses_global_env = old_env == &rtems_global_user_env; if (uses_global_env) { + bool life_protection = _Thread_Set_life_protection(true); rtems_user_env_t *new_env = calloc(1, sizeof(*new_env)); if (new_env != NULL) { @@ -83,7 +77,7 @@ rtems_status_code rtems_libio_set_private_env(void) ); if (eno == 0) { - free_user_env_protected(old_env); + rtems_libio_free_user_env(old_env); } else { sc = RTEMS_TOO_MANY; } @@ -97,6 +91,8 @@ rtems_status_code rtems_libio_set_private_env(void) } else { sc = RTEMS_NO_MEMORY; } + + _Thread_Set_life_protection(life_protection); } return sc; @@ -108,7 +104,11 @@ void rtems_libio_use_global_env(void) bool uses_private_env = env != &rtems_global_user_env; if (uses_private_env) { - free_user_env_protected(env); + bool life_protection = _Thread_Set_life_protection(true); + + rtems_libio_free_user_env(env); pthread_setspecific(rtems_current_user_env_key, NULL); + + _Thread_Set_life_protection(life_protection); } } |