diff options
author | Christian Mauderer <Christian.Mauderer@embedded-brains.de> | 2014-03-27 14:23:20 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-27 14:50:36 +0100 |
commit | 7d5c27e308632cce2052eb2aaf6a601aa0b5bc17 (patch) | |
tree | 26f46ffbd8fe4cb4523aec6b978d6532120393b9 /cpukit/libcsupport/src/privateenv.c | |
parent | m68k/mrm332: changes required to get the mrm332 bsp working again. (diff) | |
download | rtems-7d5c27e308632cce2052eb2aaf6a601aa0b5bc17.tar.bz2 |
privateenv: Remove sharing of user environment between threads.
Diffstat (limited to 'cpukit/libcsupport/src/privateenv.c')
-rw-r--r-- | cpukit/libcsupport/src/privateenv.c | 60 |
1 files changed, 4 insertions, 56 deletions
diff --git a/cpukit/libcsupport/src/privateenv.c b/cpukit/libcsupport/src/privateenv.c index c7a65a57e8..bee94c117f 100644 --- a/cpukit/libcsupport/src/privateenv.c +++ b/cpukit/libcsupport/src/privateenv.c @@ -35,13 +35,9 @@ static void free_user_env(void *arg) bool uses_global_env = env == &rtems_global_user_env; if (!uses_global_env) { - if (env->reference_count == 1) { - rtems_filesystem_global_location_release(env->current_directory); - rtems_filesystem_global_location_release(env->root_directory); - free(env); - } else { - --env->reference_count; - } + rtems_filesystem_global_location_release(env->current_directory); + rtems_filesystem_global_location_release(env->root_directory); + free(env); } } @@ -55,18 +51,14 @@ static void free_user_env_protected(rtems_user_env_t *env) rtems_status_code rtems_libio_set_private_env(void) { rtems_status_code sc = RTEMS_SUCCESSFUL; - rtems_id self_task_id = rtems_task_self(); rtems_user_env_t *old_env = rtems_current_user_env; bool uses_global_env = old_env == &rtems_global_user_env; - bool uses_shared_env = old_env->task_id != self_task_id; - if (uses_global_env || uses_shared_env) { + if (uses_global_env) { rtems_user_env_t *new_env = calloc(1, sizeof(*new_env)); if (new_env != NULL) { *new_env = *old_env; - new_env->reference_count = 1; - new_env->task_id = self_task_id; new_env->root_directory = rtems_filesystem_global_location_obtain(&old_env->root_directory); new_env->current_directory = @@ -102,50 +94,6 @@ rtems_status_code rtems_libio_set_private_env(void) return sc; } -rtems_status_code rtems_libio_share_private_env(rtems_id task_id) -{ - rtems_status_code sc = RTEMS_SUCCESSFUL; - rtems_id self_task_id = rtems_task_self(); - - if (task_id != RTEMS_SELF && self_task_id != task_id) { - rtems_user_env_t *env; - - /* - * We have to disable the thread dispatching to prevent deletion of the - * environment in the meantime. - */ - _Thread_Disable_dispatch(); - sc = rtems_task_variable_get( - task_id, - (void *) &rtems_current_user_env, - (void *) &env - ); - if (sc == RTEMS_SUCCESSFUL) { - ++env->reference_count; - } else { - sc = RTEMS_UNSATISFIED; - } - _Thread_Enable_dispatch(); - - if (sc == RTEMS_SUCCESSFUL) { - sc = rtems_task_variable_add( - RTEMS_SELF, - (void **) &rtems_current_user_env, - free_user_env - ); - if (sc == RTEMS_SUCCESSFUL) { - free_user_env_protected(rtems_current_user_env); - rtems_current_user_env = env; - } else { - free_user_env_protected(env); - sc = RTEMS_TOO_MANY; - } - } - } - - return sc; -} - void rtems_libio_use_global_env(void) { rtems_status_code sc = RTEMS_SUCCESSFUL; |