[PATCH 15/45] Filesystem: Thread life protection for env changes
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri May 15 11:41:15 UTC 2015
---
cpukit/libcsupport/src/privateenv.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/cpukit/libcsupport/src/privateenv.c b/cpukit/libcsupport/src/privateenv.c
index 5717745..29821e4 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);
}
}
--
1.8.4.5
More information about the devel
mailing list