[rtems commit] Filesystem: Thread life protection for env changes
Sebastian Huber
sebh at rtems.org
Wed May 20 07:12:03 UTC 2015
Module: rtems
Branch: master
Commit: 776a50c47a1751bf5c5957eab446d33fd50ebeae
Changeset: http://git.rtems.org/rtems/commit/?id=776a50c47a1751bf5c5957eab446d33fd50ebeae
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon May 4 09:32:00 2015 +0200
Filesystem: Thread life protection for env changes
---
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);
}
}
More information about the vc
mailing list