From 7d5c27e308632cce2052eb2aaf6a601aa0b5bc17 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Thu, 27 Mar 2014 14:23:20 +0100 Subject: privateenv: Remove sharing of user environment between threads. --- cpukit/include/rtems/userenv.h | 20 ------------- cpukit/libcsupport/src/privateenv.c | 60 +++---------------------------------- 2 files changed, 4 insertions(+), 76 deletions(-) (limited to 'cpukit') diff --git a/cpukit/include/rtems/userenv.h b/cpukit/include/rtems/userenv.h index 7d874d380f..8a9a4fcd32 100644 --- a/cpukit/include/rtems/userenv.h +++ b/cpukit/include/rtems/userenv.h @@ -64,9 +64,6 @@ typedef struct { gid_t egid; char login_buffer[LOGIN_NAME_MAX]; pid_t pgrp; /* process group id */ - /* User environment maintenance */ - rtems_id task_id; - int reference_count; } rtems_user_env_t; extern rtems_user_env_t * rtems_current_user_env; @@ -96,23 +93,6 @@ extern rtems_user_env_t rtems_global_user_env; */ rtems_status_code rtems_libio_set_private_env(void); -/** - * @brief Creates a private environment shared with another task. - * - * An attempt to share the environment with itself has no effect. This - * function must be called from normal thread context and may block on a mutex. - * Thread dispatching is disabled to protect some critical sections. - * - * @param[in] task_id The private environment is shared with the task specified - * by this identifier. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_UNSATISFIED No shared environment is available for this task - * @retval RTEMS_TOO_MANY Cannot register the shared environment. - * identifier. - */ -rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; - /** * @brief Use the global environment. * 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; -- cgit v1.2.3