diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-31 15:33:34 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-31 15:33:34 -0700 |
commit | 268fb375171668e2d85a147c7614e89ce1bd46f6 (patch) | |
tree | a28c9bbeee947155a649828578b3684f5b38aa7d /env.cpp | |
parent | ff1710131687075e819afcb045ed35924822b682 (diff) |
Cleanup proc_had_barrier
Ensure we don't try to do a universal barrier off of the main thread
Diffstat (limited to 'env.cpp')
-rw-r--r-- | env.cpp | 82 |
1 files changed, 43 insertions, 39 deletions
@@ -730,6 +730,7 @@ static env_node_t *env_get_node( const wcstring &key ) int env_set(const wchar_t *key, const wchar_t *val, int var_mode) { + ASSERT_IS_MAIN_THREAD(); env_node_t *node = NULL; bool has_changed_old = has_changed; bool has_changed_new = false; @@ -840,9 +841,9 @@ int env_set(const wchar_t *key, const wchar_t *val, int var_mode) } else { - if( !proc_had_barrier) + if( ! get_proc_had_barrier()) { - proc_had_barrier=1; + set_proc_had_barrier(true); env_universal_barrier(); } @@ -1062,7 +1063,8 @@ const wchar_t *env_var_t::c_str(void) const { env_var_t env_get_string( const wcstring &key ) { /* Big hack...we only allow getting the history on the main thread. Note that history_t may ask for an environment variable, so don't take the lock here (we don't need it) */ - if( key == L"history" && is_main_thread()) + const bool is_main = is_main_thread(); + if( key == L"history" && is_main) { env_var_t result; @@ -1100,42 +1102,44 @@ env_var_t env_get_string( const wcstring &key ) wcstring result; while( env != 0 ) - { - var_table_t::iterator result = env->env.find(key); - if ( result != env->env.end() ) - { - res = result->second; - } - else - { - res = 0; - } - - - if( res != 0 ) - { - if( res->val == ENV_NULL ) - { - return env_var_t::missing_var(); - } - else - { - return res->val; - } - } + { + var_table_t::iterator result = env->env.find(key); + if ( result != env->env.end() ) + { + res = result->second; + } + else + { + res = 0; + } - if( env->new_scope ) - { + + if( res != 0 ) + { + if( res->val == ENV_NULL ) + { + return env_var_t::missing_var(); + } + else + { + return res->val; + } + } + + if( env->new_scope ) + { env = global_env; - } - else - { + } + else + { env = env->next; - } - } - if( !proc_had_barrier) + } + } + + /* Another big hack - only do a universal barrier on the main thread (since it can change variable values) */ + if(is_main && ! get_proc_had_barrier()) { - proc_had_barrier=1; + set_proc_had_barrier(true); env_universal_barrier(); } @@ -1211,9 +1215,9 @@ int env_exist( const wchar_t *key, int mode ) if( ! (mode & ENV_LOCAL) && ! (mode & ENV_GLOBAL) ) { - if( !proc_had_barrier) + if( ! get_proc_had_barrier()) { - proc_had_barrier=1; + set_proc_had_barrier(true); env_universal_barrier(); } @@ -1453,9 +1457,9 @@ static void export_func(const std::map<wcstring, wcstring> &envs, std::vector<st static void update_export_array_if_necessary(bool recalc) { ASSERT_IS_MAIN_THREAD(); - if( recalc && !proc_had_barrier) + if( recalc && ! get_proc_had_barrier()) { - proc_had_barrier=1; + set_proc_had_barrier(true); env_universal_barrier(); } |