Permalink
Browse files

PHPEMBED: init lock needs to last longer

Summary: if it didn't, a race condition could cause one host to try to use the
interpreter before it was ready

Reviewed By: dreiss

Test Plan: ran the worker for a subset




git-svn-id: svn+ssh://tubbs/svnroot/projects/phpembed/trunk@68715 2c7ba8d8-a2f7-0310-a573-de162e16dcc7
  • Loading branch information...
1 parent 449d6f9 commit 99736a1d60d1742a05de5bf82b8540c64082dbe2 boz committed Nov 8, 2007
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/php_cxx.cpp
View
@@ -997,10 +997,10 @@ int php::init_global_php(){
#ifdef ZTS
tsrm_mutex_lock(p.init_lock);
p.clients++;
- if(p.initialized == true)
+ if(p.initialized == true){
+ tsrm_mutex_unlock(p.init_lock);
return SUCCESS;
- p.initialized = true;
- tsrm_mutex_unlock(p.init_lock);
+ }
#endif
// set up the callbacks
@@ -1055,6 +1055,11 @@ int php::init_global_php(){
zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
+#ifdef ZTS
+ p.initialized = true;
+ tsrm_mutex_unlock(p.init_lock);
+#endif
+
return SUCCESS;
// END ADAPTED php_embed_init
}

0 comments on commit 99736a1

Please sign in to comment.